test: fix Windows test for gitUtils (#6951)

* test: fix Windows test for gitUtils

* change this

* fix
This commit is contained in:
Joshua Chen 2022-03-21 20:13:40 +08:00 committed by GitHub
parent 5ee7e8c48e
commit c696dc2cd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -23,6 +23,12 @@ function createTempRepo() {
stderr: ${res.stderr} stderr: ${res.stderr}
stdout: ${res.stdout}`); stdout: ${res.stdout}`);
} }
// Doesn't matter currently
shell.exec('git config user.email "test@jc-verse.com"', {
cwd: dir,
silent: true,
});
shell.exec('git config user.name "Test"', {cwd: dir, silent: true});
} }
commit(msg: string, date: string, author: string) { commit(msg: string, date: string, author: string) {
const addRes = shell.exec('git add .', {cwd: this.dir, silent: true}); const addRes = shell.exec('git add .', {cwd: this.dir, silent: true});
@ -30,10 +36,7 @@ stdout: ${res.stdout}`);
`git commit -m "${msg}" --date "${date}T00:00:00Z" --author "${author}"`, `git commit -m "${msg}" --date "${date}T00:00:00Z" --author "${author}"`,
{ {
cwd: this.dir, cwd: this.dir,
env: { env: {GIT_COMMITTER_DATE: `${date}T00:00:00Z`},
GIT_COMMITTER_DATE: `${date}T00:00:00Z`,
GIT_COMMITTER_NAME: author,
},
silent: true, silent: true,
}, },
); );

View file

@ -53,6 +53,8 @@ export function getFileCommitDate(
); );
} }
// Commit time and author name; not using author time so that amended commits
// can have their dates updated
let formatArg = '--format=%ct'; let formatArg = '--format=%ct';
if (includeAuthor) { if (includeAuthor) {
formatArg += ',%an'; formatArg += ',%an';