Merge pull request #13661 from magnusp/feature/git-wrapper-branch-command

backend-common: wrap branch command
This commit is contained in:
Ben Lambert
2022-09-19 07:51:48 -04:00
committed by GitHub
4 changed files with 30 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-common': patch
---
The `branch` command has been added to the `isomorphic-git` wrapper.
+2
View File
@@ -342,6 +342,8 @@ export class Git {
force?: boolean;
}): Promise<void>;
// (undocumented)
branch(options: { dir: string; ref: string }): Promise<void>;
// (undocumented)
checkout(options: { dir: string; ref: string }): Promise<void>;
clone(options: {
url: string;
@@ -95,6 +95,22 @@ describe('Git', () => {
});
});
describe('branch', () => {
it('should call isomorphic-git with the correct arguments', async () => {
const git = Git.fromAuth({});
const dir = 'mockdirectory';
const ref = 'master';
await git.branch({ dir, ref });
expect(isomorphic.branch).toHaveBeenCalledWith({
fs,
dir,
ref,
});
});
});
describe('commit', () => {
it('should call isomorphic-git with the correct arguments', async () => {
const git = Git.fromAuth({});
+7
View File
@@ -94,6 +94,13 @@ export class Git {
return git.checkout({ fs, dir, ref });
}
async branch(options: { dir: string; ref: string }): Promise<void> {
const { dir, ref } = options;
this.config.logger?.info(`Creating branch {dir=${dir},ref=${ref}`);
return git.branch({ fs, dir, ref });
}
async commit(options: {
dir: string;
message: string;