Merge pull request #536 from github/sha-in-user-agent
SHA in user agent
This commit is contained in:
commit
18b9fa2671
@ -7,6 +7,5 @@ import (
|
||||
|
||||
func main() {
|
||||
commands.Run()
|
||||
|
||||
lfs.LogHttpStats()
|
||||
}
|
||||
|
18
lfs/lfs.go
18
lfs/lfs.go
@ -11,12 +11,8 @@ import (
|
||||
"github.com/github/git-lfs/vendor/_nuts/github.com/rubyist/tracerx"
|
||||
)
|
||||
|
||||
const Version = "0.5.3"
|
||||
|
||||
//
|
||||
// Setup permissions for the given directories used here.
|
||||
//
|
||||
const (
|
||||
Version = "0.5.3"
|
||||
tempDirPerms = 0755
|
||||
localMediaDirPerms = 0755
|
||||
localLogDirPerms = 0755
|
||||
@ -25,6 +21,7 @@ const (
|
||||
var (
|
||||
LargeSizeThreshold = 5 * 1024 * 1024
|
||||
TempDir = filepath.Join(os.TempDir(), "git-lfs")
|
||||
GitCommit string
|
||||
UserAgent string
|
||||
LocalWorkingDir string
|
||||
LocalGitDir string
|
||||
@ -108,10 +105,17 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
UserAgent = fmt.Sprintf("git-lfs/%s (GitHub; %s %s; go %s)", Version,
|
||||
gitCommit := ""
|
||||
if len(GitCommit) > 0 {
|
||||
gitCommit = "; git " + GitCommit
|
||||
}
|
||||
UserAgent = fmt.Sprintf("git-lfs/%s (GitHub; %s %s; go %s%s)",
|
||||
Version,
|
||||
runtime.GOOS,
|
||||
runtime.GOARCH,
|
||||
strings.Replace(runtime.Version(), "go", "", 1))
|
||||
strings.Replace(runtime.Version(), "go", "", 1),
|
||||
gitCommit,
|
||||
)
|
||||
}
|
||||
|
||||
func resolveGitDir() (string, string, error) {
|
||||
|
@ -25,26 +25,26 @@ var (
|
||||
"windows": "Windows",
|
||||
"amd64": "AMD64",
|
||||
}
|
||||
LdFlag string
|
||||
)
|
||||
|
||||
func mainBuild() {
|
||||
cmd, err := exec.Command("script/fmt").Output()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(cmd) > 0 {
|
||||
fmt.Println(string(cmd))
|
||||
}
|
||||
|
||||
if *ShowHelp {
|
||||
fmt.Println("usage: script/bootstrap [-os] [-arch] [-all]")
|
||||
flag.PrintDefaults()
|
||||
return
|
||||
}
|
||||
|
||||
buildMatrix := make(map[string]Release)
|
||||
cmd, err := exec.Command("git", "rev-parse", "--short", "HEAD").Output()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(cmd) > 0 {
|
||||
LdFlag = strings.TrimSpace("-X github.com/github/git-lfs/lfs.GitCommit " + string(cmd))
|
||||
}
|
||||
|
||||
buildMatrix := make(map[string]Release)
|
||||
errored := false
|
||||
|
||||
if *BuildAll {
|
||||
@ -128,7 +128,14 @@ func buildCommand(dir, buildos, buildarch string) error {
|
||||
bin = bin + ".exe"
|
||||
}
|
||||
|
||||
cmd := exec.Command("go", "build", "-o", bin, ".")
|
||||
args := make([]string, 1, 6)
|
||||
args[0] = "build"
|
||||
if len(LdFlag) > 0 {
|
||||
args = append(args, "-ldflags", LdFlag)
|
||||
}
|
||||
args = append(args, "-o", bin, ".")
|
||||
|
||||
cmd := exec.Command("go", args...)
|
||||
if addenv {
|
||||
cmd.Env = []string{
|
||||
"GOOS=" + buildos,
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/bin/sh
|
||||
script/fmt
|
||||
go run ./git-lfs.go "$@"
|
||||
commit=`git rev-parse --short HEAD`
|
||||
go run -ldflags="-X github.com/github/git-lfs/lfs.GitCommit $commit" ./git-lfs.go "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user