Skip to content

Commit ae860c0

Browse files
committed
patch-series: do accept GitGitGadget's push token explicitly
This completes the journey where the token is specified explicitly. If you (like I did, when developing this patch) wonder how it worked before: The Azure Pipelines set the `publishRemote` to a URL that contains the token (which is also the reason why we need stunts like the `redactGitHubToken()` method). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent e18e532 commit ae860c0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/gitgitgadget.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ export class GitGitGadget {
284284
this.publishTagsAndNotesToRemote,
285285
pr.pullRequestURL,
286286
new Date(),
287+
this.publishToken,
287288
);
288289
if (!options.noUpdate) {
289290
await this.pushNotesRef();

lib/patch-series.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ export class PatchSeries {
555555
publishTagsAndNotesToRemote?: string,
556556
pullRequestURL?: string,
557557
forceDate?: Date,
558+
publishToken?: string,
558559
): Promise<IPatchSeriesMetadata | undefined> {
559560
let globalOptions: IGitGitGadgetOptions | undefined;
560561
if (this.options.dryRun) {
@@ -822,8 +823,20 @@ export class PatchSeries {
822823
if (this.options.dryRun) {
823824
logger.log("Would publish tag");
824825
} else {
826+
const auth = [];
827+
if (publishToken) {
828+
auth.push(
829+
"-c",
830+
[
831+
`http.extraheader=Authorization:`,
832+
`Basic`,
833+
Buffer.from(`x-access-token:${publishToken}`).toString("base64"),
834+
].join(" "),
835+
);
836+
}
837+
825838
logger.log("Publishing tag");
826-
await git(["push", publishTagsAndNotesToRemote, `refs/tags/${tagName}`], {
839+
await git([...auth, "push", publishTagsAndNotesToRemote, `refs/tags/${tagName}`], {
827840
workDir: this.notes.workDir,
828841
});
829842
}

0 commit comments

Comments
 (0)