Skip to content

Commit 438c478

Browse files
author
OpenCode Agent
committed
fix: resolve VERSION_NUMBER placeholder shown in --version output
When please-cli is installed from AUR or run from source, the VERSION_NUMBER placeholder was never replaced, causing 'please -v' to print 'Please vVERSION_NUMBER' instead of the actual version. - Add git-tag fallback in display_version() when placeholder is still present (covers running from source / git clone) - Add sed replacement in PKGBUILD prepare() (covers AUR installs) - Add test asserting --version output contains a real version
1 parent 220396a commit 438c478

3 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎PKGBUILD‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ prepare() {
3636

3737
# Patching the install command in an error message.
3838
sed -i -e 's/sudo apt install libsecret-tools/sudo pacman -S libsecret/' 'please.sh'
39+
40+
# Replace VERSION_NUMBER placeholder with the actual version derived from git tags.
41+
_pkgver=$(git tag --sort=v:refname | tail -n1)
42+
sed -i -e "s/VERSION_NUMBER/${_pkgver#v}/" 'please.sh'
3943
}
4044

4145
package() {

‎please.sh‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,26 @@ function store_api_key() {
114114
done
115115
}
116116

117+
_version="VERSION_NUMBER"
118+
119+
_script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
120+
117121
display_version() {
118-
echo "Please vVERSION_NUMBER"
122+
# The placeholder VERSION_NUMBER is replaced with the actual version by the
123+
# bump-version CI workflow via sed. If it is still the literal string, the
124+
# script is running from source or an unpatched install — fall back to git tags.
125+
if [ "$_version" = "VERSION_NUMBER" ]; then
126+
if [ -d "${_script_dir}/.git" ]; then
127+
_tag=$(cd "$_script_dir" && git tag --sort=v:refname 2>/dev/null | tail -n1)
128+
if [ -n "$_tag" ]; then
129+
echo "Please v${_tag#v}"
130+
return
131+
fi
132+
fi
133+
echo "Please vVERSION_NUMBER"
134+
else
135+
echo "Please v$_version"
136+
fi
119137
}
120138

121139
display_help() {

‎test/main.bats‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ PLEASE_EXE=$BATS_TEST_DIRNAME/../please.sh
1010
@test "smoke test please --version" {
1111
result=$($PLEASE_EXE '--version')
1212
[ "${result:0:8}" == "Please v" ]
13+
[[ "${result}" != *"VERSION_NUMBER"* ]]
14+
}
15+
16+
@test "version fallback derives version from git tags" {
17+
_latest_tag=$(cd "$BATS_TEST_DIRNAME/.." && git tag --sort=v:refname | tail -n1)
18+
_latest_tag="${_latest_tag#v}"
19+
result=$($PLEASE_EXE '--version')
20+
[ "$result" == "Please v${_latest_tag}" ]
1321
}

0 commit comments

Comments
 (0)