Skip to content

Commit

Permalink
Override default branch name in deliver-work command
Browse files Browse the repository at this point in the history
Add ability to pass remote branch name to delivery_work command
Add test to delivery_work command with branch_name passed
Also readme update
  • Loading branch information
alexbeatnik authored and extsoft committed Sep 27, 2019
1 parent 5fc0935 commit 0cd61e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
7 changes: 4 additions & 3 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ echo ...
# `deliver-work`

```bash
usage: git elegant deliver-work
usage: git elegant deliver-work [branch name]
```

Updates the current branch by rebasing the default upstream branch. Then,
it pushes HEAD to appropriate upstream branch. The name of remote branch is
equal to the local one.
it pushes HEAD to appropriate upstream branch. By default, the name of remote
branch is equal to the local one. Also, you can give a custom name of
the remote branch if needed.

Approximate commands flow is
```bash
Expand Down
13 changes: 9 additions & 4 deletions libexec/git-elegant-deliver-work
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ MESSAGE

command-synopsis() {
cat <<MESSAGE
usage: git elegant deliver-work
usage: git elegant deliver-work [branch name]
MESSAGE
}

command-description() {
cat<<MESSAGE
Updates the current branch by rebasing the default upstream branch. Then,
it pushes HEAD to appropriate upstream branch. The name of remote branch is
equal to the local one.
it pushes HEAD to appropriate upstream branch. By default, the name of remote
branch is equal to the local one. Also, you can give a custom name of
the remote branch if needed.
Approximate commands flow is
\`\`\`bash
Expand All @@ -37,5 +38,9 @@ default() {
fi
git-verbose fetch
git-verbose rebase ${RMASTER}
git-verbose push --set-upstream --force origin ${BRANCH}:${BRANCH}
local REMOTE_BRANCH=${BRANCH}
if [ -n "${1}" ]; then
REMOTE_BRANCH=${1}
fi
git-verbose push --set-upstream --force origin ${BRANCH}:${REMOTE_BRANCH}
}
10 changes: 10 additions & 0 deletions tests/git-elegant-deliver-work.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ teardown() {
[[ "${lines[@]}" =~ "git push --set-upstream --force origin feature1:feature1" ]]
}

@test "'deliver-work': if branch name passed, a name of remote branch is different to local branch" {
fake-pass git branch *feature1
fake-pass git "fetch"
fake-pass git "rebase origin/master"
fake-pass git "push --set-upstream --force origin feature1:feature2"
check git-elegant deliver-work feature2
[ "$status" -eq 0 ]
[[ "${lines[@]}" =~ "git push --set-upstream --force origin feature1:feature2" ]]
}

@test "'deliver-work': exit code is 42 when current local branch is master" {
fake-pass git branch *master
fake-pass git "fetch"
Expand Down

0 comments on commit 0cd61e0

Please sign in to comment.