Skip to content

Commit

Permalink
Display current state of WIP with show-work command
Browse files Browse the repository at this point in the history
Introduced command aims to provide complete information about the
current state of work in progress. This is useful when you need to
see an overall overview of what happens just by running a single
command.

#231
  • Loading branch information
extsoft committed Dec 2, 2019
1 parent 8fcba5f commit dea0cb5
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ There are commands used in various situations such as
start-work Creates a new branch.
save-work Commits current modifications.
amend-work Amends some changes to the most recent commit.
show-work Shows a state of current work in progress.
polish-work Reapplies branch commits interactively.
deliver-work Publishes current branch to a remote repository.

Expand Down Expand Up @@ -339,6 +340,24 @@ Release notes
- Add `release-work` command
```

# `show-work`

```bash
usage: git elegant show-work
```

Shows a state of current work by displaying branch information, new commits
comparing to `master` branch, uncommitted modifications, and available
stashes.

Approximate commands flow is
```bash
==>> git elegant show-work
git log --oneline master..@
git status --short
git stash list
```

# `start-work`

```bash
Expand Down
1 change: 1 addition & 0 deletions libexec/git-elegant
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ $(--print-command-in-usage prune-repository)
$(--print-command-in-usage start-work)
$(--print-command-in-usage save-work)
$(--print-command-in-usage amend-work)
$(--print-command-in-usage show-work)
$(--print-command-in-usage polish-work)
$(--print-command-in-usage deliver-work)
Expand Down
56 changes: 56 additions & 0 deletions libexec/git-elegant-show-work
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash
set -e

command-purpose() {
cat <<MESSAGE
Shows a state of current work in progress.
MESSAGE
}

command-synopsis() {
cat <<MESSAGE
usage: git elegant show-work
MESSAGE
}

command-description() {
cat<<MESSAGE
Shows a state of current work by displaying branch information, new commits
comparing to \`master\` branch, uncommitted modifications, and available
stashes.
Approximate commands flow is
\`\`\`bash
==>> git elegant show-work
git log --oneline ${MASTER}..@
git status --short
git stash list
\`\`\`
MESSAGE
}

default(){
local branch=$(git rev-parse --abbrev-ref @)
info-text ">>> Work branch:"
info-text "local: ${branch}"
local upstream=$(git rev-parse --abbrev-ref ${branch}@{upstream} 2>/dev/null || echo)
if [[ -n ${upstream} ]]; then
info-text "remote: ${upstream}"
fi
info-text ""
if [[ -n $(git rev-list ${MASTER}..${branch}) ]]; then
info-text ">>> New commits (comparing to 'master' branch):"
git log --oneline ${MASTER}..${branch}
info-text ""
fi
if [[ -n $(git status --short) ]]; then
info-text ">>> Unsaved modifications:"
git status --short
info-text ""
fi
if [[ -n $(git stash list) ]]; then
info-text ">>> Available stashes:"
git stash list
info-text ""
fi
}
1 change: 1 addition & 0 deletions tests/git-elegant-show-commands.bats
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ teardown() {
"init-repository"
"start-work"
"save-work"
"show-work"
"deliver-work"
"accept-work"
"obtain-work"
Expand Down

0 comments on commit dea0cb5

Please sign in to comment.