Skip to content

Commit

Permalink
Merge pull request #2721 from oliver-sanders/git-worktree
Browse files Browse the repository at this point in the history
better test for git working copy
  • Loading branch information
matthewrmshin authored Jul 19, 2018
2 parents 32629c7 + 54c1f9f commit 0bbac0b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions bin/cylc
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ HELP_OPTS=('help' '--help' '-h' 'h' '?')
get_version() {
# If there is a version file present, use that
if [[ -f "${CYLC_DIR}/VERSION" ]]; then
CYLC_VERSION="$(cat ${CYLC_DIR}/VERSION)"
# Otherwise, use git (if in a git repo) to determine version
elif [[ -d "${CYLC_DIR}/.git" ]]; then
CYLC_VERSION="$(cd ${CYLC_DIR} && git describe --abbrev=4 --always)"
CYLC_VERSION="$(cat "${CYLC_DIR}/VERSION")"
# Otherwise, use git (if in a git repo and not a bare clone)
# to determine version
elif git -C "${CYLC_DIR}" rev-parse && \
[[ -n "$(git -C "${CYLC_DIR}" rev-parse --show-toplevel)" ]]; then
CYLC_VERSION="$(cd "${CYLC_DIR}" && git describe --abbrev=4 --always)"
# Append "-dirty" if there are uncommitted changes.
if [[ -n "$(cd ${CYLC_DIR} && git status \
if [[ -n "$(cd "${CYLC_DIR}" && git status \
--untracked-files=no --porcelain)" ]]; then
CYLC_VERSION="${CYLC_VERSION}-dirty"
fi
Expand Down

0 comments on commit 0bbac0b

Please sign in to comment.