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

Fix setting commit & vendor variables via make #5141

Merged
merged 2 commits into from Oct 13, 2022

Conversation

rcoup
Copy link
Contributor

@rcoup rcoup commented Oct 13, 2022

087db1d (#4911) bumped the git-lfs Go package version to v3, but the variables being set in the Makefile for GitCommit & Vendor didn't change, which meant setting them had no effect. Fix this by updating the variable paths.

In addition, quote the Vendor variable so it can have spaces in it.

Before (main@ d3716c9):

$ make bin/git-lfs VENDOR=WorldOfGooCorp
...
GOOS= GOARCH= go build -ldflags="-X github.com/git-lfs/git-lfs/config.Vendor=WorldofGooCorp -X github.com/git-lfs/git-lfs/config.GitCommit=d3716c90 -s -w " -gcflags=" " -trimpath -o ./bin/git-lfs ./git-lfs.go
$ bin/git-lfs version
git-lfs/3.2.0 (GitHub; darwin arm64; go 1.19.1)

$ make bin/git-lfs "VENDOR=World of Goo Corporation"
...
GOOS= GOARCH= go build -ldflags="-X github.com/git-lfs/git-lfs/config.Vendor=World of Goo Corporation -X github.com/git-lfs/git-lfs/config.GitCommit=d3716c90 -s -w " -gcflags=" " -trimpath -o ./bin/git-lfs ./git-lfs.go
# command-line-arguments
usage: link [options] main.o
...
make: *** [Makefile:318: bin/git-lfs] Error 2

After:

$ make bin/git-lfs "VENDOR=World of Goo Corporation"
...
GOOS= GOARCH= go build -ldflags="-X 'github.com/git-lfs/git-lfs/v3/config.Vendor=World of Goo Corporation' -X github.com/git-lfs/git-lfs/v3/config.GitCommit=8d300427 -s -w " -gcflags=" " -trimpath -o ./bin/git-lfs ./git-lfs.go
$ bin/git-lfs version
git-lfs/3.2.0 (World of Goo Corporation; darwin arm64; go 1.19.1; git 8d300427)

087db1d bumped the package version to v3, but the variables being set
in the Makefile for GitCommit & Vendor didn't change, which meant the
action had no effect. Fix this by updating the variable paths.
Add simple quoting to the ldflags argument
@rcoup rcoup requested a review from a team as a code owner October 13, 2022 11:34
Copy link
Member

@bk2204 bk2204 left a comment

Choose a reason for hiding this comment

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

This looks good. Thanks for the patch.

@bk2204
Copy link
Member

bk2204 commented Oct 13, 2022

The CI fix is #5142.

@bk2204 bk2204 merged commit 3ddb46f into git-lfs:main Oct 13, 2022
@rcoup rcoup deleted the v3-fix-build-version-vars branch October 13, 2022 22:22
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.

None yet

2 participants