Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add omb version #621

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/cli.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,26 @@ function _omb_cmd_update {
echo 'Not yet implemented'
}
function _omb_cmd_version {
echo 'Not yet implemented'
if ! _omb_util_command_exists git; then
echo "git not available to determine version"
return 1
fi

# Get the version name:
# 1) try tag-like version
# 2) try branch name
# 3) try name-rev (tag~<rev> or branch~<rev>)
Comment on lines +33 to +35
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the branch name useful to identify the version? A branch name is a moving target.

local version
version=$(command git -C "$OSH" describe --tags HEAD 2>/dev/null) \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
version=$(command git -C "$OSH" describe --tags HEAD 2>/dev/null) \
version=$(command git --git-dir="$OSH" describe --tags HEAD 2>/dev/null) \

See #311 for details. Sadly, CentOS was discontinued, yet many large systems continue to stay in CentOS 7. The same for the other occurrences of -C "$OSH"

|| version=$(command git -C "$OSH" symbolic-ref --quiet --short HEAD 2>/dev/null) \
|| version=$(command git -C "$OSH" name-rev --no-undefined --name-only --exclude="remotes/*" HEAD 2>/dev/null) \
|| version="<detached>"

# Get short hash for the current HEAD
local commit=$(command git -C "$OSH" rev-parse --short HEAD 2>/dev/null)

# Show version and commit hash
printf "%s (%s)\n" "$version" "$commit"
}

function omb {
Expand Down
Loading