Skip to content

Commit

Permalink
[prebuilds] remove "addLabel"
Browse files Browse the repository at this point in the history
Closes #3303
  • Loading branch information
AlexTugarev committed Jul 14, 2021
1 parent 9ffcfd4 commit e304354
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions components/server/ee/src/prebuilds/github-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export class GithubApp {
const prebuildStartPromise = this.onPrStartPrebuild({ span }, config, owner, ctx);
this.onPrAddCheck({ span }, config, ctx, prebuildStartPromise);
this.onPrAddBadge(config, ctx);
this.onPrAddLabel(config, ctx, prebuildStartPromise);
this.onPrAddComment(config, ctx);
} catch (e) {
TraceContext.logError({ span }, e);
Expand Down Expand Up @@ -288,44 +287,6 @@ export class GithubApp {
updatePrPromise.catch(err => log.error(err, "Error while updating PR body", { contextURL }));
}

protected onPrAddLabel(config: WorkspaceConfig | undefined, ctx: Context, prebuildStartPromise: Promise<StartPrebuildResult> | undefined) {
const pr = ctx.payload.pull_request;
if (this.appRules.shouldDo(config, "addLabel") === true) {
const label =
config
&& config.github
&& config.github.prebuilds
&& GithubAppPrebuildConfig.is(config.github.prebuilds)
&& typeof config.github.prebuilds.addLabel === 'string'
? config.github.prebuilds.addLabel as string
: "prebuilt-in-gitpod";

if (ctx.payload.action === 'synchronize') {
// someone just pushed a commit, remove the label
const delLabelPromise = ctx.octokit.issues.removeLabel({ ...ctx.repo(), number: pr.number, name: label });
delLabelPromise.catch(err => log.error(err, "Error while removing label from PR"));
}

if (prebuildStartPromise) {
prebuildStartPromise.then(startWsResult => {
if (startWsResult.done) {
if (!!startWsResult.didFinish) {
const addLabelPromise = ctx.octokit.issues.addLabels({ ...ctx.repo(), number: pr.number, labels: [label] });
addLabelPromise.catch(err => log.error(err, "Error while adding label to PR"));
}
} else {
new PrebuildListener(this.messageBus, startWsResult.wsid, evt => {
if (!HeadlessWorkspaceEventType.isRunning(evt) && HeadlessWorkspaceEventType.didFinish(evt)) {
const addLabelPromise = ctx.octokit.issues.addLabels({ ...ctx.repo(), number: pr.number, labels: [label] });
addLabelPromise.catch(err => log.error(err, "Error while adding label to PR"));
}
});
}
})
}
}
}

protected async onPrAddComment(config: WorkspaceConfig | undefined, ctx: Context) {
if (!this.appRules.shouldDo(config, 'addComment')) {
return;
Expand Down

0 comments on commit e304354

Please sign in to comment.