-
Notifications
You must be signed in to change notification settings - Fork 23
fix: resolve VERSION_NUMBER placeholder shown in --version output #69
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -114,8 +114,27 @@ function store_api_key() { | |||||||||||||||||||||||||
| done | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| _version="VERSION_NUMBER" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| _script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| display_version() { | ||||||||||||||||||||||||||
| echo "Please vVERSION_NUMBER" | ||||||||||||||||||||||||||
| # The placeholder VERSION_NUMBER is replaced with the actual version by the | ||||||||||||||||||||||||||
| # bump-version CI workflow via sed. If it is still the literal string, the | ||||||||||||||||||||||||||
| # script is running from source or an unpatched install — fall back to git tags. | ||||||||||||||||||||||||||
| if [ "$_version" = "VERSION_NUMBER" ]; then | ||||||||||||||||||||||||||
| if [ -d "${_script_dir}/.git" ]; then | ||||||||||||||||||||||||||
| local _tag | ||||||||||||||||||||||||||
| _tag=$(cd "$_script_dir" && git tag --sort=v:refname 2>/dev/null | tail -n1) | ||||||||||||||||||||||||||
|
Comment on lines
+124
to
+128
|
||||||||||||||||||||||||||
| # script is running from source or an unpatched install — fall back to git tags. | |
| if [ "$_version" = "VERSION_NUMBER" ]; then | |
| if [ -d "${_script_dir}/.git" ]; then | |
| _tag=$(cd "$_script_dir" && git tag --sort=v:refname 2>/dev/null | tail -n1) | |
| # script is running from source or an unpatched install — fall back to a tag | |
| # that describes the currently checked-out commit. | |
| if [ "$_version" = "VERSION_NUMBER" ]; then | |
| if [ -d "${_script_dir}/.git" ]; then | |
| _tag=$(cd "$_script_dir" && git describe --tags --exact-match 2>/dev/null) | |
| if [ -z "$_tag" ]; then | |
| _tag=$(cd "$_script_dir" && git describe --tags --abbrev=0 2>/dev/null) | |
| fi |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,4 +10,15 @@ PLEASE_EXE=$BATS_TEST_DIRNAME/../please.sh | |
| @test "smoke test please --version" { | ||
| result=$($PLEASE_EXE '--version') | ||
| [ "${result:0:8}" == "Please v" ] | ||
| [[ "${result}" != *"VERSION_NUMBER"* ]] | ||
| } | ||
|
|
||
| @test "version fallback derives version from git tags" { | ||
| _latest_tag=$(cd "$BATS_TEST_DIRNAME/.." && git tag --sort=v:refname | tail -n1) | ||
| if [ -z "$_latest_tag" ]; then | ||
| skip "No git tags available" | ||
| fi | ||
| _latest_tag="${_latest_tag#v}" | ||
| result=$($PLEASE_EXE '--version') | ||
| [ "$result" == "Please v${_latest_tag}" ] | ||
|
Comment on lines
+16
to
+23
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_tagis assigned insidedisplay_version()without being declared local, which leaks a global variable into the script’s environment. Declare it as a local variable within the function to avoid unintended side effects with other globals.