Skip to content

Commit 767656c

Browse files
thePunderWomandevversion
authored andcommitted
refactor(github-actions/commit-message-based-labels): prevent auto removal of already applied labels
If a commit message does not match our patterns and a label has already been applied manually, this action would remove the labels, which would add the PR back to the triage queue. Instead, this will never remove an already added label.
1 parent 7c67703 commit 767656c

File tree

2 files changed

+0
-30
lines changed

2 files changed

+0
-30
lines changed

github-actions/commit-message-based-labels/lib/main.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ class CommitMessageBasedLabelManager {
4949
if (hasCommit && !hasLabel) {
5050
await this.addLabel(name);
5151
}
52-
if (!hasCommit && hasLabel) {
53-
await this.removeLabel(name);
54-
}
5552
}
5653

5754
for (const commit of this.commits) {
@@ -78,19 +75,6 @@ class CommitMessageBasedLabelManager {
7875
}
7976
}
8077

81-
/** Remove the provided label from the pull request. */
82-
async removeLabel(name: string) {
83-
const {number: issue_number, owner, repo} = context.issue;
84-
try {
85-
await this.git.issues.removeLabel({repo, owner, issue_number, name});
86-
core.info(`Added ${name} label to PR #${issue_number}`);
87-
this.labels.delete(name);
88-
} catch (err) {
89-
core.error(`Failed to add ${name} label to PR #${issue_number}`);
90-
core.debug(err as string);
91-
}
92-
}
93-
9478
/** Initialize the current labels and commits for the PR. */
9579
async initialize() {
9680
const {number, owner, repo} = context.issue;

github-actions/commit-message-based-labels/main.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43655,9 +43655,6 @@ var CommitMessageBasedLabelManager = class {
4365543655
if (hasCommit && !hasLabel) {
4365643656
await this.addLabel(name);
4365743657
}
43658-
if (!hasCommit && hasLabel) {
43659-
await this.removeLabel(name);
43660-
}
4366143658
}
4366243659
for (const commit of this.commits) {
4366343660
const label = "area: " + commit.scope;
@@ -43677,17 +43674,6 @@ var CommitMessageBasedLabelManager = class {
4367743674
core.debug(err);
4367843675
}
4367943676
}
43680-
async removeLabel(name) {
43681-
const { number: issue_number, owner, repo } = import_github2.context.issue;
43682-
try {
43683-
await this.git.issues.removeLabel({ repo, owner, issue_number, name });
43684-
core.info(`Added ${name} label to PR #${issue_number}`);
43685-
this.labels.delete(name);
43686-
} catch (err) {
43687-
core.error(`Failed to add ${name} label to PR #${issue_number}`);
43688-
core.debug(err);
43689-
}
43690-
}
4369143677
async initialize() {
4369243678
const { number, owner, repo } = import_github2.context.issue;
4369343679
await this.git.paginate(this.git.issues.listLabelsForRepo, { owner, repo }).then((labels) => labels.filter((l) => l.name.startsWith("area: ")).forEach((l) => this.repoAreaLabels.add(l.name)));

0 commit comments

Comments
 (0)