Skip to content

Commit

Permalink
Use original git's exit code when deliver work
Browse files Browse the repository at this point in the history
There is a case when a push does not provide a URL to open. In this
case, Elegant Git should continue the flow. But it stops as
`[[ ... ]] && ...` construction with a `for` cycle sets exit code 1 if
`[[ ... ]]` returns false. That's why a regular `if` used instead.
  • Loading branch information
extsoft committed Oct 18, 2019
1 parent 45e21fa commit 87415eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libexec/git-elegant-deliver-work
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ MESSAGE
--open-urls-if-possible() {
type open >/dev/null 2>&1 || { echo "${1}"; return 0; }
for line in ${1}; do
[[ ${line} =~ ^http(.+) ]] && open ${line}
if [[ ${line} =~ (^http)(.+) ]]; then
open ${line}
fi
done
}

Expand Down
8 changes: 8 additions & 0 deletions tests/git-elegant-deliver-work.bats
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,11 @@ teardown() {
check git-elegant deliver-work
[[ "${status}" -eq 23 ]]
}

@test "'deliver-work': exit 0 if URls are not present in the push output" {
repo "git checkout -b feature1"
fake-pass "git push --set-upstream --force origin feature1:feature1" "Branch 'workflows' set up to track remote branch 'workflows' from 'origin'."
fake "open https://pull/new/some" 23
check git-elegant deliver-work
[[ "${status}" -eq 0 ]]
}

0 comments on commit 87415eb

Please sign in to comment.