Skip to content

Fix version badge for non-Docker installs - #459

Open
JoeJoeflyn wants to merge 1 commit into
basecamp:mainfrom
JoeJoeflyn:fix/version-badge-not-showing
Open

Fix version badge for non-Docker installs#459
JoeJoeflyn wants to merge 1 commit into
basecamp:mainfrom
JoeJoeflyn:fix/version-badge-not-showing

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Jul 28, 2026

Copy link
Copy Markdown

The version badge fell back to "0" whenever APP_VERSION wasn't set as an env var, which happens for fresh clones without a tagged release.

Fall back through a VERSION file and git describe --tags --always before reaching "0".

Fixes #447.

Copilot AI review requested due to automatic review settings July 28, 2026 13:10

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@JoeJoeflyn JoeJoeflyn changed the title Fix version badge showing 0 for non-Docker installs Fix version badge for non-Docker installs Jul 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes the app’s version badge incorrectly showing 0 in non-Docker installs by improving how the application determines app_version, and by baking a VERSION file into the exported source ZIP.

Changes:

  • Update app_version initialization to fall back through VERSION and git describe before defaulting to "0".
  • Add a helper test for version_badge rendering.
  • Write (and clean up) a VERSION file during bin/release source export, and ignore it in git.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

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

File Description
config/initializers/version.rb Implements version fallback chain (ENV → VERSION file → git describe → "0").
test/helpers/version_helper_test.rb Adds coverage for version_badge HTML rendering.
bin/release Writes a VERSION file into the source ZIP export and attempts cleanup afterward.
.gitignore Prevents locally-generated VERSION from being committed.

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

Comment on lines +2 to +7
version_file = Rails.root.join("VERSION")
if version_file.exist?
version_file.read.strip
else
`git describe --tags --always 2>/dev/null`.strip.presence || "0"
end
assert_equal '<span class="product__version-badge">1.2.0</span>', version_badge
end

test "version_badge renders fallback zero when no version is set" do
Comment on lines +1 to +7
Rails.application.config.app_version = ENV.fetch("APP_VERSION") do
version_file = Rails.root.join("VERSION")
if version_file.exist?
version_file.read.strip
else
`git describe --tags --always 2>/dev/null`.strip.presence || "0"
end
Fall back through a VERSION file and `git describe --tags --always`
before reaching "0", so the badge renders correctly for fresh clones
without a tagged release.

Fixes basecamp#447.
Copilot AI review requested due to automatic review settings July 28, 2026 13:14
@JoeJoeflyn
JoeJoeflyn force-pushed the fix/version-badge-not-showing branch from 3bbab9e to 455777f Compare July 28, 2026 13:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (3)

config/initializers/version.rb:6

  • If the VERSION file exists but is empty/whitespace, this currently sets app_version to an empty string, which will render a blank badge and blank X-Version header. Consider treating blank VERSION contents as “not set” and falling back to git describe … (and then "0").
  version_file = Rails.root.join("VERSION")
  if version_file.exist?
    version_file.read.strip
  else
    `git describe --tags --always 2>/dev/null`.strip.presence || "0"

test/helpers/version_helper_test.rb:17

  • This test name says it covers the “no version is set” case, but it explicitly sets app_version to "0". Renaming the test will make it accurately describe what’s being asserted.
  test "version_badge renders fallback zero when no version is set" do

config/initializers/version.rb:7

  • The initializer now contains fallback logic (VERSION file -> git describe -> "0"), but there’s no test coverage verifying these paths. Adding tests around the version resolution (e.g., extracting it to a small method/class that can be unit-tested while stubbing ENV, file existence/contents, and the git command) would prevent regressions.
Rails.application.config.app_version = ENV.fetch("APP_VERSION") do
  version_file = Rails.root.join("VERSION")
  if version_file.exist?
    version_file.read.strip
  else
    `git describe --tags --always 2>/dev/null`.strip.presence || "0"
  end

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.

Writebook version not showing up

2 participants