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

command line switches like --version not being interpretted correctly #249

Open
notjames opened this issue Jul 26, 2023 · 2 comments
Open

Comments

@notjames
Copy link

When running git-chglog (or git chglog) --version or -v, chglog generates a changelog instead of showing the current version.

Expected Behavior

version of chglog and exit -- no generated content.

Actual Behavior

generated content and no version

Steps to Reproduce (including precondition)

git-chglog --version
git-chglog -v

Screenshot on This Problem (if possible)

not reasonable

Your Environment

  • OS: Linux, Ubuntu 22.04 (Jammy)
  • git-chglog version: {Please write here} -- :) would love to, but can't.
@VioletCranberry
Copy link

I have just encountered this issue.

If you install the git-chglog with go install, then these ldflags are not taken into account due to how the release process is set up and how version variable is defined. You'll need to do something like this:

go install -ldflags "-X main.version=1.2.3" github.com/git-chglog/git-chglog/cmd/git-chglog@latest
❯ git-chglog --version                                                                              
git-chglog version 1.2.3

Using any other installation methods mentioned in README.md will rely on binaries built by GoReleaser that sets main.version ldflag by default. For example:

❯ curl -Lo git-chlog.tar.gz https://github.com/git-chglog/git-chglog/releases/download/v0.15.4/git-chglog_0.15.4_darwin_arm64.tar.gz && tar -xzvf git-chlog.tar.gz
❯ ./git-chglog --version
git-chglog version 0.15.4

@davidalpert
Copy link

I have worked around this in several ways in my own projects, most often by using a build script to generate a go file with version constants and updating that as part of my release process so that the source code always includes a version number and the go install pattern will work without requiring the client to juggle ldflags

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

No branches or pull requests

3 participants