Adding support for removing file from git index

Signed-off-by: manuel.falcon <manuel.falcon@glovoapp.com>
This commit is contained in:
manuel.falcon
2023-12-23 11:28:51 +01:00
parent 31783a711c
commit 3b24eaecbc
3 changed files with 30 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/backend-common': minor
---
Adding support for removing file from git index
@@ -63,6 +63,22 @@ describe('Git', () => {
});
});
describe('remove', () => {
it('should call isomorphic-git remove with the correct arguments', async () => {
const git = Git.fromAuth({});
const dir = 'mockdirectory';
const filepath = 'mockfile/path';
await git.remove({ dir, filepath });
expect(isomorphic.remove).toHaveBeenCalledWith({
fs,
dir,
filepath,
});
});
});
describe('deleteRemote', () => {
it('should call isomorphic-git with the correct arguments', async () => {
const git = Git.fromAuth({});
+9
View File
@@ -300,6 +300,15 @@ export class Git {
return git.readCommit({ fs, dir, oid: sha });
}
/** https://isomorphic-git.org/docs/en/remove */
async remove(options: { dir: string; filepath: string }): Promise<void> {
const { dir, filepath } = options;
this.config.logger?.info(
`Removing file from git index {dir=${dir},filepath=${filepath}}`,
);
return git.remove({ fs, dir, filepath });
}
/** https://isomorphic-git.org/docs/en/resolveRef */
async resolveRef(options: { dir: string; ref: string }): Promise<string> {
const { dir, ref } = options;