Skip to content

Commit 28df660

Browse files
authored
fix(create-pr): Add user identity for commits (#720)
1 parent 3f95295 commit 28df660

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

dist/440.index.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/440.index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/helpers/create-pr.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ const getOrCreateHeadBranch = async ({ head, branch_name, commit_message }: Part
4747
if (branch_name && commit_message) {
4848
const git = simpleGit();
4949

50+
await git.addConfig('user.name', 'github-actions[bot]');
51+
await git.addConfig('user.email', 'github-actions[bot]@users.noreply.github.com');
52+
5053
await git.checkoutLocalBranch(branch_name);
5154
await git.add('.');
5255
await git.commit(commit_message);

test/helpers/create-pr.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ jest.mock('simple-git', () => {
3333
checkoutLocalBranch: jest.fn(),
3434
add: jest.fn(),
3535
commit: jest.fn(),
36-
push: jest.fn()
36+
push: jest.fn(),
37+
addConfig: jest.fn()
3738
};
3839

3940
const simpleGitMock = jest.fn(() => mockGit);
@@ -177,6 +178,8 @@ describe('createPr', () => {
177178

178179
const git = (simpleGit as unknown as MockSimpleGit).__mockGitInstance;
179180

181+
expect(git.addConfig).toHaveBeenCalledWith('user.name', 'github-actions[bot]');
182+
expect(git.addConfig).toHaveBeenCalledWith('user.email', 'github-actions[bot]@users.noreply.github.com');
180183
expect(git.checkoutLocalBranch).toHaveBeenCalledWith(branch_name);
181184
expect(git.add).toHaveBeenCalledWith('.');
182185
expect(git.commit).toHaveBeenCalledWith(commit_message);

test/types.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { SimpleGit } from 'simple-git';
1616
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1717
export type Mocktokit = jest.MockInstance<any, any[]>;
1818

19-
export type MockSimpleGit = jest.MockedFunction<() => jest.Mocked<Pick<SimpleGit, 'checkoutLocalBranch' | 'add' | 'commit' | 'push'>>> & {
20-
__mockGitInstance: jest.Mocked<Pick<SimpleGit, 'checkoutLocalBranch' | 'add' | 'commit' | 'push'>>;
19+
export type MockSimpleGit = jest.MockedFunction<
20+
() => jest.Mocked<Pick<SimpleGit, 'checkoutLocalBranch' | 'add' | 'commit' | 'push' | 'addConfig'>>
21+
> & {
22+
__mockGitInstance: jest.Mocked<Pick<SimpleGit, 'checkoutLocalBranch' | 'add' | 'commit' | 'push' | 'addConfig'>>;
2123
};

0 commit comments

Comments
 (0)