Skip to content

Commit

Permalink
Display installed version of Elegant Git
Browse files Browse the repository at this point in the history
The version will be automatically read from the git history and placed
into a file. Elegant Git will read it from the file when a user requests
a version.

Also, `--depth` is set 50 in order to make `git describe` always
working. We usually make small releases and the number should guarantee
stable execution.

#198
  • Loading branch information
extsoft committed Oct 4, 2019
1 parent 3cc98c4 commit a708187
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .workflows/ci-pipeline.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pipeline() {
./install.bash /usr/local src
echo "'Unknown command' testing..."
git elegant unknown-command | grep "Unknown command: git elegant unknown-command"
echo "Check installation of version's file..."
git elegant --version || exit 1
) || fail "Installation test is failed."
mkdocs build --clean --strict || fail "Unable to build the documentation."
pdd --exclude=.idea/**/* \
Expand Down
5 changes: 3 additions & 2 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

An assistant who carefully makes routine work with Git.

usage: git elegant [-h|--help|help]
usage: git elegant [-h | --help | help]
or: git elegant [-v | --version | version]
or: git elegant <command> [args]
or: git elegant <command> [-h|--help|help]
or: git elegant <command> [-h | --help | help]


There are commands used in various situations such as
Expand Down
16 changes: 13 additions & 3 deletions install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ copy(){
install -m 644 ${FROM}/completions/* ${INTO}/completions
install -m 644 ${FROM}/LICENSE ${INTO}
install -m 644 ${FROM}/README.md ${INTO}
install -m 644 ${FROM}/version ${INTO}
}

next-steps() {
Expand All @@ -34,6 +35,12 @@ Then, please restart the terminal and enjoy the 'elegant git'!
TEXT
}

add-version() {
cd "${1}"
git describe >> version
cd -
}

main() {
if [[ -n ${1} ]]; then
INSTALL_PATH="${1}"
Expand All @@ -43,13 +50,16 @@ main() {
# mode selection
if [[ -z ${1} ]]; then
local CODE="/tmp/elegant-git"
git clone --quiet --depth 1 ${REPO_HOME} ${CODE}
git clone --quiet --depth 50 ${REPO_HOME} ${CODE}
add-version ${CODE}
copy ${CODE} ${INSTALL_PATH}
rm -r ${CODE}
else
copy ${0%/*} ${INSTALL_PATH}
local path="${0%/*}"
add-version "${path}"
copy "${path}" ${INSTALL_PATH}
fi
echo "'elegant git' is installed to '${INSTALL_PATH}/bin/git-elegant'."
echo "Elegant Git is installed to '${INSTALL_PATH}/bin/git-elegant'."
echo "
The final step after installation is to run
git elegant acquire-repository
Expand Down
10 changes: 6 additions & 4 deletions libexec/git-elegant
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ remove-file() {
An assistant who carefully makes routine work with Git.
usage: git elegant [-h|--help|help]
usage: git elegant [-h | --help | help]
or: git elegant [-v | --version | version]
or: git elegant <command> [args]
or: git elegant <command> [-h|--help|help]
or: git elegant <command> [-h | --help | help]
There are commands used in various situations such as
Expand Down Expand Up @@ -141,8 +142,9 @@ main() {
local COMMAND="none"
[[ -n "$1" ]] && COMMAND="$1" && shift
case "${COMMAND}" in
none|-h|--help|help) --usage ;;
*) --run-command ${COMMAND} "$@" ;;
none|-h|--help|help) --usage ;;
-v|--version|version) cat "${BINS}/../version" ;;
*) --run-command ${COMMAND} "$@" ;;
esac
}

Expand Down
7 changes: 6 additions & 1 deletion tests/git-elegant.bats
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ load addons-common
echo "Check presence of '${COMMAND}'"
[[ "${lines[@]}" =~ "${COMMAND}" ]]
done
}
}

@test "'git elegant': a version is displayed correctly" {
check git-elegant --version
[[ "${lines[@]}" =~ "/eg/tests/../libexec/../version" ]]
}

0 comments on commit a708187

Please sign in to comment.