Skip to content

fix: resolve VERSION_NUMBER placeholder shown in --version output#69

Open
JonathanRohland-TNG wants to merge 1 commit intoTNG:mainfrom
JonathanRohland-TNG:fix/version-placeholder
Open

fix: resolve VERSION_NUMBER placeholder shown in --version output#69
JonathanRohland-TNG wants to merge 1 commit intoTNG:mainfrom
JonathanRohland-TNG:fix/version-placeholder

Conversation

@JonathanRohland-TNG
Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes please --version printing the unreplaced VERSION_NUMBER placeholder when running from a source checkout or when installed via AUR packaging.

Changes:

  • Add a display_version() fallback that derives the version from git tags when the placeholder is still present.
  • Patch the AUR PKGBUILD to sed-replace the placeholder during prepare().
  • Extend BATS tests to assert --version no longer contains VERSION_NUMBER, and to validate the git-tag fallback behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
test/main.bats Adds assertions ensuring --version is a real version and matches the derived git-tag fallback.
please.sh Introduces _version placeholder variable and git-tag fallback logic in display_version().
PKGBUILD Adds prepare() step to replace the VERSION_NUMBER placeholder using a git-derived version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread please.sh
# 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
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

_tag is assigned inside display_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.

Suggested change
if [ -d "${_script_dir}/.git" ]; then
if [ -d "${_script_dir}/.git" ]; then
local _tag

Copilot uses AI. Check for mistakes.
Comment thread PKGBUILD Outdated
Comment on lines +40 to +42
# Replace VERSION_NUMBER placeholder with the actual version derived from git tags.
_pkgver=$(git tag --sort=v:refname | tail -n1)
sed -i -e "s/VERSION_NUMBER/${_pkgver#v}/" 'please.sh'
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

prepare() replaces VERSION_NUMBER using the highest tag in the repository, not necessarily the tag for the checked-out commit. This can produce an incorrect embedded version when building a specific release (VERSION set) or building from a commit that isn’t at the latest tag. Prefer deriving the tag from the current HEAD (or use $VERSION when it’s set), and handle the case where no tag is found so you don’t replace the placeholder with an empty string.

Suggested change
# Replace VERSION_NUMBER placeholder with the actual version derived from git tags.
_pkgver=$(git tag --sort=v:refname | tail -n1)
sed -i -e "s/VERSION_NUMBER/${_pkgver#v}/" 'please.sh'
# Replace VERSION_NUMBER with the version for the checked-out revision.
if [ -n "$VERSION" ]; then
_pkgver="$VERSION"
else
_pkgver=$(git tag --points-at HEAD --sort=v:refname | tail -n1)
fi
if [ -n "$_pkgver" ]; then
sed -i -e "s/VERSION_NUMBER/${_pkgver#v}/" 'please.sh'
fi

Copilot uses AI. Check for mistakes.
Comment thread test/main.bats
Comment on lines +16 to +20
@test "version fallback derives version from git tags" {
_latest_tag=$(cd "$BATS_TEST_DIRNAME/.." && git tag --sort=v:refname | tail -n1)
_latest_tag="${_latest_tag#v}"
result=$($PLEASE_EXE '--version')
[ "$result" == "Please v${_latest_tag}" ]
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

These tests assume the local checkout has git tags available. In GitHub Actions, actions/checkout often fetches a shallow clone without tags, which would make _latest_tag empty and also make please --version fall back to printing VERSION_NUMBER, failing both assertions. Consider skipping these assertions when no tags are present, or adjust the test setup to ensure tags are fetched/available before running the tests.

Copilot uses AI. Check for mistakes.
Comment thread please.sh
Comment on lines +124 to +127
# 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)
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

The fallback version is derived from the highest tag in the repo (git tag --sort=v:refname | tail -n1), which can be incorrect if the user is on an older commit/branch (it can report a tag that doesn't point to the checked-out commit). Consider deriving the version from the current commit (e.g., nearest tag reachable from HEAD / tag pointing at HEAD) so --version reflects the code being executed.

Suggested change
# 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

Copilot uses AI. Check for mistakes.
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

Signed-off-by: OpenCode Agent <agent@tngtech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants