-
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.
Make stashing verbose for
start-work
command
The introduced `pipe` plugin gives ability to execute a command through a wrapper function which runs pre- and/or post-conditions. For now, there is an ability to make automatic stash if there are some uncommitted changes, and apply them back after the wrapped command is executed. Use `git rev-parse --abbrev-ref HEAD` to display a name of the current branch. As the result: 1. it will be executed faster 2. removes `*` prefix from the branch name Use `$@` always in double-quotes. This makes correct parameters propagation for all arguments.
- Loading branch information
Showing
12 changed files
with
91 additions
and
34 deletions.
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,10 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
# Runs bats tests | ||
# usage: ./script [command name] | ||
|
||
if [[ -n "${1}" ]]; then | ||
bats --tap $(find tests -type f -name "*${1}*") | ||
else | ||
bats --tap tests | ||
fi |
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
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
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
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
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
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,23 @@ | ||
#!/usr/bin/env bash | ||
# The plugin which allows running a given functions through different types | ||
# (aka pre- and post-conditions). | ||
|
||
stash-pipe() { | ||
# Makes automatic stash and unstash if possible | ||
# usage: stash-pipe <command> [args]... | ||
|
||
git update-index -q --refresh | ||
if ! git diff-index --quiet HEAD --; then | ||
local message="Elegant Git auto-stash: " | ||
message+="WIP in '$(git rev-parse --abbrev-ref HEAD)' branch " | ||
message+="on $(date "+%Y-%m-%dT%H:%M:%S")" | ||
git-verbose stash push --message "${message}" | ||
fi | ||
|
||
"${@}" | ||
|
||
if [[ -n "${message}" ]]; then | ||
git update-index -q --refresh | ||
git-verbose stash pop $(git stash list --grep="${message}" --format="%gd") | ||
fi | ||
} |
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
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
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
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
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,32 @@ | ||
#!/usr/bin/env bash | ||
set -ex | ||
|
||
testing() { | ||
docker run -it --rm -v $PWD:/eg beeshive/elegant-git-ci:3 ./.wf/tests-execution.bash $@ | ||
} | ||
|
||
repository() { | ||
docker run -idt --rm --name repository --workdir /tmp/elegant-git-repo -v $PWD:/eg beeshive/elegant-git-ci:3 bash | ||
docker exec -it repository bash -c "source /eg/tests/addons-git.bash;source /eg/tests/addons-common.bash; init-repo" | ||
docker attach repository | ||
} | ||
|
||
commands=( | ||
testing | ||
repository | ||
) | ||
|
||
main() { | ||
local command=${1} | ||
if [[ -z "${command}" ]]; then | ||
select any in ${commands[@]}; do | ||
command=${any} | ||
break | ||
done | ||
else | ||
shift | ||
fi | ||
${command} ${@} | ||
} | ||
|
||
main ${@} |