Skip to content

Commit

Permalink
Don't remove fork remote branch when accept-work
Browse files Browse the repository at this point in the history
Add check of remote branch to git-elegant accept-work command if remote
branch is not origin/... script do not delete it
Also add test for this functionality
bees-hive#171
  • Loading branch information
alexbeatnik committed Sep 29, 2019
1 parent 0cd61e0 commit 7ee46b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion libexec/git-elegant-accept-work
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@ default() {
git-verbose merge --ff-only ${WORK_BRANCH}
git-verbose push ${REMOTE_NAME} ${MASTER}:${MASTER}
git-verbose branch --delete --force ${WORK_BRANCH}
git-verbose push ${REMOTE_NAME} --delete $(branch-from-remote-reference ${ACTUAL_REMOTE})
if [[ ${REMOTE_NAME} == *"origin"* ]]; then
git-verbose push ${REMOTE_NAME} --delete $(branch-from-remote-reference ${ACTUAL_REMOTE})
fi

}
15 changes: 14 additions & 1 deletion tests/git-elegant-accept-work.bats
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ teardown() {
clean-fake
}

@test "'accept-work': a work is accepted successfully for given remote branch" {
@test "'accept-work': a work is accepted successfully for given origin remote branch" {
fake-pass git "elegant obtain-work some __eg"
fake-pass git "status"
fake-pass git "rebase origin/master"
Expand All @@ -22,6 +22,19 @@ teardown() {
[[ "$status" -eq 0 ]]
}

@test "'accept-work': a work is accepted successfully for given no origin remote branch" {
fake-pass git "elegant obtain-work some __eg"
fake-pass git "status"
fake-pass git "rebase feature/master"
fake-pass git "checkout master"
fake-pass git "merge --ff-only __eg"
fake-pass git "push feature master:master"
fake-pass git "branch --delete --force __eg"

check git-elegant accept-work some
[[ "$status" -eq 0 ]]
}

@test "'accept-work': exit code is 45 when remote branch name isn't set" {
check git-elegant accept-work
[[ "$status" -eq 45 ]]
Expand Down

0 comments on commit 7ee46b7

Please sign in to comment.