Skip to content

Commit

Permalink
fix: set commit author as local config
Browse files Browse the repository at this point in the history
Close #151

Co-authored-by: Ryo Ota <[email protected]>
  • Loading branch information
peaceiris and nwtgck committed Mar 11, 2020
1 parent 6801987 commit fb7a067
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/git-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,21 @@ export async function setConfig(
userName: string,
userEmail: string
): Promise<void> {
await exec.exec('git', ['config', '--global', 'gc.auto', '0']);

let name = '';
if (userName) {
name = userName;
} else {
name = `${process.env.GITHUB_ACTOR}`;
}
await exec.exec('git', ['config', '--global', 'user.name', name]);
await exec.exec('git', ['config', 'user.name', name]);

let email = '';
if (userName !== '' && userEmail !== '') {
email = userEmail;
} else {
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
}
await exec.exec('git', ['config', '--global', 'user.email', email]);
await exec.exec('git', ['config', 'user.email', email]);

return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function run(): Promise<void> {
const inps: Inputs = getInputs();
showInputs(inps);

await git.setConfig(inps.UserName, inps.UserEmail);
await exec.exec('git', ['config', '--global', 'gc.auto', '0']);

const remoteURL = await setTokens(inps);
core.debug(`[INFO] remoteURL: ${remoteURL}`);
Expand All @@ -31,7 +31,7 @@ export async function run(): Promise<void> {
}
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
await exec.exec('git', ['add', '--all']);

await git.setConfig(inps.UserName, inps.UserEmail);
await git.commit(
inps.AllowEmptyCommit,
inps.ExternalRepository,
Expand Down

0 comments on commit fb7a067

Please sign in to comment.