Skip to content

Commit eccd2cb

Browse files
committed
notes: optionally accept a token to push with
Previously, the token was automagically looked up via the Git config. However, it is better to be less automagic about it, and pass it through from the `CIHelper` (who will learn about the token in the next commits). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 20410eb commit eccd2cb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/git-notes.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ type TemporaryNoteIndex = {
1919
};
2020

2121
export class GitNotes {
22-
public async push(url: string) {
22+
public async push(url: string, token: string | undefined = undefined): Promise<void> {
23+
const auth = !token
24+
? []
25+
: [
26+
"-c",
27+
`http.extraheader=Authorization: Basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`,
28+
];
2329
for (const backoff of [50, 500, 2000, 5000, 20000, 0]) {
2430
try {
25-
await git(["push", url, "--", `${this.notesRef}`], {
31+
await git([...auth, "push", url, "--", `${this.notesRef}`], {
2632
workDir: this.workDir,
2733
});
2834
} catch (e) {

0 commit comments

Comments
 (0)