Merge pull request #13661 from magnusp/feature/git-wrapper-branch-command
backend-common: wrap branch command
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/backend-common': patch
|
||||
---
|
||||
|
||||
The `branch` command has been added to the `isomorphic-git` wrapper.
|
||||
@@ -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({});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user