Skip to content

Commit e18e532

Browse files
committed
misc-helper: do configure the token for pushing the Git notes
When merging gitgitgadget/gitgitgadget#1473 (Add support for distributed notes updates), I did not anticipate that the current Azure Pipelines were not prepared for that: Contrary to what I had remembered, they did _not_ simply configure `http.extraHeader` to be able to push (which is somewhat surprising because I authored them, and I typically did that a lot in the olden days). Happily, I _just_ introduced support for configuring a token in `CIHelper` that is specifically used for accessing `gitgitgadget/git`, including the Git notes pushes. Let's teach `misc-helper` about this new trick, and pick up the token that was configured via `set-app-token` and tell `CIHelper` to use it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 9aa666f commit e18e532

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

script/misc-helper.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,27 +72,38 @@ const commandOptions = commander.opts<ICommanderOptions>();
7272

7373
const ci = new CIHelper(await getGitGitWorkDir(), commandOptions.skipUpdate, commandOptions.gitgitgadgetWorkDir);
7474

75+
const configureNotesPushToken = async (): Promise<void> => {
76+
const token = await gitConfig("gitgitgadget.githubToken");
77+
if (!token) {
78+
throw new Error("No token configured for gitgitgadget.githubToken");
79+
}
80+
ci.setAccessToken("gitgitgadget", token);
81+
};
82+
7583
const argv = commander.args;
7684
commander = new Command().version("1.0.0");
7785
commander
7886
.usage("[options] command")
7987
.command("update-open-prs")
8088
.description("Update GitGitGadget's idea of what PRs are open")
8189
.action(async () => {
90+
await configureNotesPushToken();
8291
const result = await ci.updateOpenPrs();
8392
console.log(`Updated notes: ${result}`);
8493
});
8594
commander
8695
.command("update-commit-mappings")
8796
.description("Determine which commits correspond to which open PRs")
8897
.action(async () => {
98+
await configureNotesPushToken();
8999
const result = await ci.updateCommitMappings();
90100
console.log(`Updated notes: ${result}`);
91101
});
92102
commander
93103
.command("handle-open-prs")
94104
.description("Handle open PRs, i.e. look whether they have been integrated into upstream Git")
95105
.action(async () => {
106+
await configureNotesPushToken();
96107
const options = await ci.getGitGitGadgetOptions();
97108
if (!options.openPRs) {
98109
throw new Error("No open PRs?");
@@ -437,6 +448,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
437448
"Handle a comment on a Pull Request",
438449
async (repositoryOwner: string, commentID: string) => {
439450
if (repositoryOwner === undefined) repositoryOwner = config.repo.owner;
451+
await configureNotesPushToken();
440452
await ci.handleComment(repositoryOwner, parseInt(commentID, 10));
441453
},
442454
true,
@@ -447,6 +459,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
447459
"handle-pr-push",
448460
"Handle a push to a Pull Request",
449461
async (repositoryOwner: string, prNumber: string) => {
462+
await configureNotesPushToken();
450463
await ci.handlePush(repositoryOwner, parseInt(prNumber, 10));
451464
},
452465
true,
@@ -456,6 +469,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
456469
.command("handle-new-mails")
457470
.description("Handle new mails in the mail archive")
458471
.action(async () => {
472+
await configureNotesPushToken();
459473
const mailArchiveGitDir = await getVar("loreGitDir", commandOptions.gitgitgadgetWorkDir);
460474

461475
if (!mailArchiveGitDir) {

0 commit comments

Comments
 (0)