Skip to content

Commit

Permalink
Describe exit codes
Browse files Browse the repository at this point in the history
In order to keep consistency, all exit codes are documented and
applied in accordance with their purpose. Also, they will be used
as a base for further development.

#73
  • Loading branch information
extsoft committed Jul 29, 2019
1 parent f27b399 commit 8b75777
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 10 deletions.
5 changes: 4 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,7 @@ Support only one default remote - `origin`.
Usually, Elegant Git translates exit codes of original Git commands. However, in some cases,
it may face its own errors and raises them as

- `81` - a philosophical constraint
- `0` - a successful execution
- `42` - a philosophical constraint
- `45` - a required parameter is empty
- `46` - an unknown command
4 changes: 2 additions & 2 deletions libexec/git-elegant
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ _error-if-empty() {
# _error-if-empty <a value to check> <error message>
if [[ -z "$1" ]]; then
__rm "$2"
exit -1
exit 45
fi
}

Expand Down Expand Up @@ -100,7 +100,7 @@ main() {
local COMMAND="help"
[[ -n "$1" ]] && COMMAND="$1" && shift
[[ "$COMMAND" = "help" ]] && usage && exit 0
[[ ! -e "$BINS/git-elegant-$COMMAND" ]] && echo "Unknown command: git elegant $COMMAND" && usage && exit 2
[[ ! -e "$BINS/git-elegant-$COMMAND" ]] && echo "Unknown command: git elegant $COMMAND" && usage && exit 46
. "$BINS/git-elegant-$COMMAND"

default "$@"
Expand Down
2 changes: 1 addition & 1 deletion libexec/git-elegant-deliver-work
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default() {
local BRANCH=$(__branches 'git branch | grep \*')
if [[ "$BRANCH" == "master" ]]; then
box "No pushes to 'master' branch. Please read more on ${__site}"
exit 81
exit 42
fi
boxtee git fetch
boxtee git rebase ${RMASTER}
Expand Down
4 changes: 2 additions & 2 deletions tests/git-elegant-accept-work.bats
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ teardown() {
[ "$status" -eq 0 ]
}

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

@test "'accept-work': print error message when remote branch name isn't set" {
Expand Down
4 changes: 2 additions & 2 deletions tests/git-elegant-deliver-work.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ teardown() {
[ "${lines[7]}" = "== git push --set-upstream --force origin feature1:feature1 ==" ]
}

@test "'deliver-work': raise error #81 if current local branch is master" {
@test "'deliver-work': exit code is 42 when current local branch is master" {
fake-pass git branch *master
fake-pass git "fetch"
fake-pass git "rebase origin/master"
fake-pass git "push --set-upstream --force origin master:master"
check git-elegant deliver-work
[ "$status" -eq 81 ]
[ "$status" -eq 42 ]
[ "${lines[1]}" = "== No pushes to 'master' branch. Please read more on https://elegant-git.bees-hive.org ==" ]
}
4 changes: 2 additions & 2 deletions tests/git-elegant-start-work.bats
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ teardown() {
[ "$status" -eq 0 ]
}

@test "'start-work': exit code is 255 when branch name isn't set" {
@test "'start-work': exit code is 45 when branch name isn't set" {
check git-elegant start-work
[ "$status" -eq 255 ]
[ "$status" -eq 45 ]
}

@test "'start-work': print error message when branch name isn't set" {
Expand Down

0 comments on commit 8b75777

Please sign in to comment.