feat: add --git-client to explicitly set the type of forge (#106)

codeberg is running Forgejo and it may not be possible to infer that
from the URL alone. The same is true for GitHub Enterprise Server.
This commit is contained in:
Earl Warren 2024-03-23 17:13:14 +01:00 committed by GitHub
parent 646d8fe41c
commit 80a0b554f0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 70 additions and 3 deletions

View file

@ -768,4 +768,23 @@ describe("gha runner", () => {
});
expect(GitHubClient.prototype.createPullRequest).toReturnTimes(3);
});
test("explicitly set git client", async () => {
spyGetInput({
"target-branch": "target",
"pull-request": "https://api.github.com/repos/owner/reponame/pulls/2368",
"git-client": "codeberg",
});
await runner.execute();
const cwd = process.cwd() + "/bp";
expect(GitClientFactory.getOrCreate).toBeCalledTimes(1);
expect(GitClientFactory.getOrCreate).toBeCalledWith(GitClientType.CODEBERG, undefined, "https://api.github.com");
expect(GitCLIService.prototype.clone).toBeCalledTimes(1);
expect(GitCLIService.prototype.clone).toBeCalledWith("https://github.com/owner/reponame.git", cwd, "target");
});
});