diff --git a/.changeset/thick-tables-give.md b/.changeset/thick-tables-give.md new file mode 100644 index 0000000000..e6b4026e51 --- /dev/null +++ b/.changeset/thick-tables-give.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-node': patch +--- + +Use `branch` function instead of `checkout` function when creating branch diff --git a/plugins/scaffolder-node/src/actions/gitHelpers.test.ts b/plugins/scaffolder-node/src/actions/gitHelpers.test.ts index 85fb9ba2e6..7a61e592ec 100644 --- a/plugins/scaffolder-node/src/actions/gitHelpers.test.ts +++ b/plugins/scaffolder-node/src/actions/gitHelpers.test.ts @@ -32,6 +32,7 @@ jest.mock('../scm', () => ({ init: jest.fn(), add: jest.fn(), checkout: jest.fn(), + branch: jest.fn(), commit: jest .fn() .mockResolvedValue('220f19cc36b551763d157f1b5e4a4b446165dbd6'), @@ -444,7 +445,7 @@ describe('createBranch', () => { }); it('create the branch', () => { - expect(mockedGit.checkout).toHaveBeenCalledWith({ + expect(mockedGit.branch).toHaveBeenCalledWith({ ref: 'trunk', dir: '/tmp/repo/dir/', }); @@ -460,7 +461,7 @@ describe('createBranch', () => { }, }); - expect(mockedGit.checkout).toHaveBeenCalledWith({ + expect(mockedGit.branch).toHaveBeenCalledWith({ ref: 'trunk', dir: '/tmp/repo/dir/', }); diff --git a/plugins/scaffolder-node/src/actions/gitHelpers.ts b/plugins/scaffolder-node/src/actions/gitHelpers.ts index 04f47d1648..9f2d5709a7 100644 --- a/plugins/scaffolder-node/src/actions/gitHelpers.ts +++ b/plugins/scaffolder-node/src/actions/gitHelpers.ts @@ -178,7 +178,7 @@ export async function createBranch(options: { logger, }); - await git.checkout({ dir, ref }); + await git.branch({ dir, ref }); } /**