AddAuthorInfo adds environment variables to `cmd.Env` that set the Git author and committer to known values and set the timestamp to `*timestamp`. Then `*timestamp` is moved forward by a minute, so that each commit gets a unique timestamp.
(cmd *exec.Cmd, timestamp *time.Time)
| 269 | // `*timestamp`. Then `*timestamp` is moved forward by a minute, so |
| 270 | // that each commit gets a unique timestamp. |
| 271 | func AddAuthorInfo(cmd *exec.Cmd, timestamp *time.Time) { |
| 272 | cmd.Env = append(cmd.Env, |
| 273 | "GIT_AUTHOR_NAME=Arthur", |
| 274 | "GIT_AUTHOR_EMAIL=arthur@example.com", |
| 275 | fmt.Sprintf("GIT_AUTHOR_DATE=%d -0700", timestamp.Unix()), |
| 276 | "GIT_COMMITTER_NAME=Constance", |
| 277 | "GIT_COMMITTER_EMAIL=constance@example.com", |
| 278 | fmt.Sprintf("GIT_COMMITTER_DATE=%d -0700", timestamp.Unix()), |
| 279 | ) |
| 280 | *timestamp = timestamp.Add(60 * time.Second) |
| 281 | } |
| 282 | |
| 283 | // ConfigAdd adds a key-value pair to the gitconfig in `repo`. |
| 284 | func (repo *TestRepo) ConfigAdd(t *testing.T, key, value string) { |