Skip to content

Commit

Permalink
Log the git version
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Jun 9, 2024
1 parent d75844a commit 12a7d9c
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,18 +622,6 @@ func main() {
}
}

// Don't pollute the user's .gitconfig if this is being run directly.
if f, err := os.CreateTemp("", "git-sync.gitconfig.*"); err != nil {
log.Error(err, "ERROR: can't create gitconfig file")
os.Exit(1)
} else {
gitConfig := f.Name()
f.Close()
os.Setenv("GIT_CONFIG_GLOBAL", gitConfig)
os.Setenv("GIT_CONFIG_NOSYSTEM", "true")
log.V(2).Info("created private gitconfig file", "path", gitConfig)
}

// Capture the various git parameters.
git := &repoSync{
cmd: *flGitCmd,
Expand All @@ -655,6 +643,26 @@ func main() {
// no long-running operations like `git fetch`, so hopefully 30 seconds will be enough.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)

// Log the git version.
if ver, _, err := cmdRunner.Run(ctx, "", nil, *flGitCmd, "version"); err != nil {
log.Error(err, "can't get git version")
os.Exit(1)
} else {
log.V(0).Info("git version", "version", ver)
}

// Don't pollute the user's .gitconfig if this is being run directly.
if f, err := os.CreateTemp("", "git-sync.gitconfig.*"); err != nil {
log.Error(err, "ERROR: can't create gitconfig file")
os.Exit(1)
} else {
gitConfig := f.Name()
f.Close()
os.Setenv("GIT_CONFIG_GLOBAL", gitConfig)
os.Setenv("GIT_CONFIG_NOSYSTEM", "true")
log.V(2).Info("created private gitconfig file", "path", gitConfig)
}

// Set various configs we want, but users might override.
if err := git.SetupDefaultGitConfigs(ctx); err != nil {
log.Error(err, "can't set default git configs")
Expand Down

0 comments on commit 12a7d9c

Please sign in to comment.