config: allow vendors to customize the version info

It's common for vendors (such as Linux distros) to want to customize the
User-Agent string and version information for software they provide.
This is valuable for vendors, but it also allows troubleshooting
problems with custom patches that may have been applied by the vendor.
Allow vendors to set a VENDOR makefile flag to set the vendor field for
the User-Agent and version information.
This commit is contained in:
brian m. carlson 2019-05-08 18:40:24 +00:00
parent 97d75e1af4
commit a8c3d8f070
No known key found for this signature in database
GPG Key ID: 2D0C9BC12F82B3A1
2 changed files with 9 additions and 1 deletions

@ -22,6 +22,9 @@ GO_TEST_EXTRA_ARGS =
# the config.GitCommit variable is always set via this variable, and # the config.GitCommit variable is always set via this variable, and
# DWARF-stripping is enabled unless DWARF=YesPlease. # DWARF-stripping is enabled unless DWARF=YesPlease.
BUILTIN_LD_FLAGS = BUILTIN_LD_FLAGS =
ifneq ("$(VENDOR)","")
BUILTIN_LD_FLAGS += -X github.com/git-lfs/git-lfs/config.Vendor=$(VENDOR)
endif
BUILTIN_LD_FLAGS += -X github.com/git-lfs/git-lfs/config.GitCommit=$(GIT_LFS_SHA) BUILTIN_LD_FLAGS += -X github.com/git-lfs/git-lfs/config.GitCommit=$(GIT_LFS_SHA)
ifneq ("$(DWARF)","YesPlease") ifneq ("$(DWARF)","YesPlease")
BUILTIN_LD_FLAGS += -s BUILTIN_LD_FLAGS += -s

@ -9,6 +9,7 @@ import (
var ( var (
GitCommit string GitCommit string
VersionDesc string VersionDesc string
Vendor string
) )
const ( const (
@ -20,8 +21,12 @@ func init() {
if len(GitCommit) > 0 { if len(GitCommit) > 0 {
gitCommit = "; git " + GitCommit gitCommit = "; git " + GitCommit
} }
VersionDesc = fmt.Sprintf("git-lfs/%s (GitHub; %s %s; go %s%s)", if len(Vendor) == 0 {
Vendor = "GitHub"
}
VersionDesc = fmt.Sprintf("git-lfs/%s (%s; %s %s; go %s%s)",
Version, Version,
Vendor,
runtime.GOOS, runtime.GOOS,
runtime.GOARCH, runtime.GOARCH,
strings.Replace(runtime.Version(), "go", "", 1), strings.Replace(runtime.Version(), "go", "", 1),