Skip to content

Commit d011ae5

Browse files
committed
CIHelper: move the responsibility to push from handleOpenPRs() to handlePR()
We already push the notes ref when updating the PR metadata (i.e. the object attached to the blob whose contents are the PR URL), therefore it makes only sense to combine that with any update to the GitGitGadgetOptions (i.e. the object attached to the empty object). This simplifies the logic (and the separation of concerns) quite a bit. Suggested-by: Chris. Webster <chris@webstech.net> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 57beda4 commit d011ae5

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

lib/ci-helper.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -251,34 +251,23 @@ export class CIHelper {
251251
/**
252252
* Process all open PRs.
253253
*
254-
* @returns true if `refs/notes/gitgitgadget` was updated (and needs to
255-
* be pushed)
254+
* @returns true if `refs/notes/gitgitgadget` was updated
256255
*/
257256
public async handleOpenPRs(): Promise<boolean> {
258257
const options = await this.getGitGitGadgetOptions();
259258
if (!options.openPRs) {
260259
return false;
261260
}
262261
let result = false;
263-
let optionsUpdated = false;
264262
for (const pullRequestURL in options.openPRs) {
265263
if (!Object.prototype.hasOwnProperty.call(options.openPRs, pullRequestURL)) {
266264
continue;
267265
}
268266
console.log(`Handling ${pullRequestURL}`);
269-
const [notesUpdated, optionsUpdated2] = await this.handlePR(pullRequestURL, options);
270-
if (notesUpdated) {
267+
const [notesUpdated, optionsUpdated] = await this.handlePR(pullRequestURL, options);
268+
if (notesUpdated || optionsUpdated) {
271269
result = true;
272270
}
273-
if (optionsUpdated2) {
274-
optionsUpdated = true;
275-
}
276-
}
277-
278-
if (optionsUpdated) {
279-
await this.notes.set("", options, true);
280-
await this.notes.push(this.urlRepo);
281-
result = true;
282271
}
283272

284273
return result;
@@ -416,6 +405,9 @@ export class CIHelper {
416405

417406
if (optionsUpdated) {
418407
await this.notes.set("", options, true);
408+
}
409+
410+
if (notesUpdated || optionsUpdated) {
419411
await this.notes.push(this.urlRepo);
420412
}
421413

0 commit comments

Comments
 (0)