diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f4c69419..d860f031d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to `src-cli` are documented in this file. ### Fixed - `src campaigns` output has been improved in the Windows console. [#274](https://github.com/sourcegraph/src-cli/pull/274) +- `src campaigns` will no longer generate warnings if `user.name` or `user.email` have not been set in the global Git configuration. [#277](https://github.com/sourcegraph/src-cli/pull/277) ## 3.18.0 diff --git a/internal/campaigns/run_steps.go b/internal/campaigns/run_steps.go index 41a4b4ecdb..76fd1699cf 100644 --- a/internal/campaigns/run_steps.go +++ b/internal/campaigns/run_steps.go @@ -49,6 +49,18 @@ func runSteps(ctx context.Context, client api.Client, repo *graphql.Repository, if _, err := runGitCmd("init"); err != nil { return nil, errors.Wrap(err, "git init failed") } + + // Set user.name and user.email in the local repository. The user name and + // e-mail will eventually be ignored anyway, since we're just using the Git + // repository to generate diffs, but we don't want git to generate alarming + // looking warnings. + if _, err := runGitCmd("config", "--local", "user.name", "Sourcegraph"); err != nil { + return nil, errors.Wrap(err, "git config user.name failed") + } + if _, err := runGitCmd("config", "--local", "user.email", "campaigns@sourcegraph.com"); err != nil { + return nil, errors.Wrap(err, "git config user.email failed") + } + // --force because we want previously "gitignored" files in the repository if _, err := runGitCmd("add", "--force", "--all"); err != nil { return nil, errors.Wrap(err, "git add failed")