-
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.
The command automates tags creation. Also, `addons-read.bash` supports custom answers for the questions. This gives more flexibility on manipulation with input parameters during the testing.
- Loading branch information
Showing
8 changed files
with
187 additions
and
3 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
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,76 @@ | ||
#!/usr/bin/env bash | ||
|
||
command-purpose() { | ||
cat <<MESSAGE | ||
Releases available work as a new annotated tag. | ||
MESSAGE | ||
} | ||
|
||
command-synopsis() { | ||
cat <<MESSAGE | ||
usage: git elegant release-work [tag name] | ||
MESSAGE | ||
} | ||
|
||
command-description() { | ||
cat<<MESSAGE | ||
Annotates the latest commit of \`master\` branch with a given tag and publishes | ||
it. The tag's message will be prepopulated using commits subjects (from oldest | ||
to newest) between the last available tag and HEAD. The release notes will be | ||
either copied to clipboard (if \`pbcopy\` or \`xclip\` is available) or printed | ||
to standard output using \`git elegant show-release-notes\`. | ||
Prior to the execution, a current state is saved (a branch with modifications). | ||
After the successful command execution, the state will be restored. In the case | ||
of a failure, you need to go to the desired branch and apply a stash if needed. | ||
Approximate commands flow is | ||
\`\`\`bash | ||
==>> git elegant release-work 1.2.0 | ||
git checkout master | ||
git pull --tags | ||
git tag --annotate --file tag-message --edit 1.2.0 | ||
git push --tags | ||
git elegant show-release-notes smart 1.1.12 1.2.0 | ||
\`\`\` | ||
MESSAGE | ||
} | ||
|
||
--release-work() { | ||
git-verbose checkout ${MASTER} | ||
git-verbose pull --tags | ||
local new_tag="${1}" | ||
local last_tag=$(git for-each-ref --sort "-version:refname" --format "%(refname:short)" refs/tags --count 1) | ||
if [[ -z ${new_tag} ]]; then | ||
question-text "'${last_tag}' is the last tag. Which one will be next? " | ||
read new_tag | ||
fi | ||
local message="tag-message" | ||
echo "Release ${new_tag}" >> ${message} | ||
echo "" >> ${message} | ||
git log ${last_tag}...@ --pretty=format:'- %s' --reverse >> ${message} | ||
echo "" >> ${message} | ||
echo "" >> ${message} | ||
git-verbose tag --annotate --file ${message} --edit ${new_tag} | ||
remove-file ${message} | ||
git-verbose push --tags | ||
|
||
|
||
local default_tool="cat" | ||
local copy_tool=${default_tool} | ||
# mac | ||
which pbcopy >/dev/null && copy_tool="pbcopy" | ||
# linux | ||
which xclip >/dev/null && copy_tool="xclip -selection clipboard" | ||
( | ||
git-verbose elegant show-release-notes smart ${last_tag} ${new_tag} | ||
) | ${copy_tool} | ||
if [[ ! "${default_tool}" == "${copy_tool}" ]]; then | ||
info-text "The release notes are copied to clipboard." | ||
fi | ||
|
||
} | ||
|
||
default() { | ||
stash-pipe branch-pipe --release-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
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,47 @@ | ||
#!/usr/bin/env bats -ex | ||
|
||
load addons-common | ||
load addons-fake | ||
load addons-repo | ||
load addons-read | ||
|
||
first=first.txt | ||
second=second.txt | ||
third=third.txt | ||
new_tag=3.0.0 | ||
|
||
setup() { | ||
repo-new | ||
repo-commit-file ${first} | ||
repo "git tag -a -m ${first} 1" | ||
repo-commit-file ${second} | ||
repo "git tag -a -m ${second} 2" | ||
repo-commit-file ${third} | ||
repo "git tag -a -m ${third} ${new_tag}" | ||
repo "git tag && git log --oneline" | ||
fake-pass "git pull --tags" | ||
fake-pass "git push --tags" | ||
fake-pass "git tag --annotate --file tag-message --edit ${new_tag}" | ||
fake-fail "which pbcopy" | ||
fake-fail "which xclip" | ||
fake-pass "git remote get-url origin" "https://fake-repo.git" | ||
read-answer ${new_tag} | ||
} | ||
|
||
teardown() { | ||
fake-clean | ||
repo-clean | ||
read-clean | ||
} | ||
|
||
@test "'release-work': release work when a new tag is provided as argument" { | ||
check git-elegant release-work ${new_tag} | ||
[[ "${status}" -eq 0 ]] | ||
[[ "${lines[@]}" =~ "Release notes" ]] | ||
} | ||
|
||
@test "'release-work': release work when a new tag is provided via question" { | ||
check git-elegant release-work | ||
[[ "${status}" -eq 0 ]] | ||
[[ "${lines[@]}" =~ "Release notes" ]] | ||
} |