mirror of
https://code.forgejo.org/actions/git-backporting.git
synced 2025-05-14 01:29:12 -04:00
fix: --auth when --git-user contains space (#95)
Since --git-user is a user-facing name, it's common to include a space in it. As such, it's not suitable to use as a username in a Git remote URL. GitLab documented that it doesn't (yet?) check for username [1], and from my testing GitHub doesn't seem to care either. So just use an arbitrary name as a username. [1] https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html
This commit is contained in:
parent
d4dc510af1
commit
9bcd6e6b55
4 changed files with 27 additions and 6 deletions
|
@ -123,4 +123,22 @@ describe("git cli service", () => {
|
|||
const post = spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd }).stdout.toString().trim();
|
||||
expect(post).toEqual("tbranch");
|
||||
});
|
||||
|
||||
test("git clone set url with auth correctly for API token", async () => {
|
||||
const git2 = new GitCLIService("api-token", {
|
||||
user: "Backporting bot",
|
||||
email: "bot@example.com",
|
||||
});
|
||||
const cwd2 = `${__dirname}/test-api-token`;
|
||||
|
||||
try {
|
||||
await git2.clone(`file://${cwd}`, cwd2, "main");
|
||||
const remoteURL = spawnSync("git", ["remote", "get-url", "origin"], { cwd: cwd2 }).stdout.toString().trim();
|
||||
|
||||
expect(remoteURL).toContain("api-token");
|
||||
expect(remoteURL).not.toContain("Backporting bot");
|
||||
} finally {
|
||||
fs.rmSync(cwd2, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue