-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit implement issue #125 Add comand amend-work to amend changes also add test for amend-work command
- Loading branch information
1 parent
8138793
commit 4df04b6
Showing
4 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
default(){ | ||
local BRANCH=$(__branches 'git branch | grep \*') | ||
if [[ "$BRANCH" == "master" ]]; then | ||
box "No commits to 'master' branch. Please read more on ${__site}" | ||
box "Try 'git elegant start-work' prior to retrying this command." | ||
exit 42 | ||
fi | ||
boxtee git add --interactive | ||
boxtee git diff --cached --check | ||
boxtee git commit --amend | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ default() { | |
echo "obtain-work" | ||
echo "clear-local" | ||
echo "commands" | ||
echo "amend-work" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bats | ||
|
||
load addons-common | ||
load addons-fake | ||
load addons-read | ||
load addons-git | ||
|
||
setup() { | ||
init-repo | ||
} | ||
|
||
teardown() { | ||
clean-fake | ||
clean-git | ||
} | ||
|
||
@test "'amend-work': command works as expected for non-master branch" { | ||
fake-pass git "add --interactive" | ||
fake-pass git "diff --cached --check" | ||
fake-pass git "commit --amend" | ||
gitrepo git checkout -b test | ||
check git-elegant amend-work | ||
[[ "${status}" -eq 0 ]] | ||
} | ||
|
||
@test "'amend-work': exit code is 42 when current local branch is master" { | ||
check git-elegant amend-work | ||
[[ "${status}" -eq 42 ]] | ||
[[ "${lines[@]}" =~ "== No commits to 'master' branch. Please read more on https://elegant-git.bees-hive.org ==" ]] | ||
[[ "${lines[@]}" =~ "== Try 'git elegant start-work' prior to retrying this command. ==" ]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters