Skip to content

refactor(github-actions/commit-message-based-labels): prevent auto removal of already applied labels #2824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions github-actions/commit-message-based-labels/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ class CommitMessageBasedLabelManager {
if (hasCommit && !hasLabel) {
await this.addLabel(name);
}
if (!hasCommit && hasLabel) {
await this.removeLabel(name);
}
}

for (const commit of this.commits) {
Expand All @@ -78,19 +75,6 @@ class CommitMessageBasedLabelManager {
}
}

/** Remove the provided label from the pull request. */
async removeLabel(name: string) {
const {number: issue_number, owner, repo} = context.issue;
try {
await this.git.issues.removeLabel({repo, owner, issue_number, name});
core.info(`Added ${name} label to PR #${issue_number}`);
this.labels.delete(name);
} catch (err) {
core.error(`Failed to add ${name} label to PR #${issue_number}`);
core.debug(err as string);
}
}

/** Initialize the current labels and commits for the PR. */
async initialize() {
const {number, owner, repo} = context.issue;
Expand Down
14 changes: 0 additions & 14 deletions github-actions/commit-message-based-labels/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -43655,9 +43655,6 @@ var CommitMessageBasedLabelManager = class {
if (hasCommit && !hasLabel) {
await this.addLabel(name);
}
if (!hasCommit && hasLabel) {
await this.removeLabel(name);
}
}
for (const commit of this.commits) {
const label = "area: " + commit.scope;
Expand All @@ -43677,17 +43674,6 @@ var CommitMessageBasedLabelManager = class {
core.debug(err);
}
}
async removeLabel(name) {
const { number: issue_number, owner, repo } = import_github2.context.issue;
try {
await this.git.issues.removeLabel({ repo, owner, issue_number, name });
core.info(`Added ${name} label to PR #${issue_number}`);
this.labels.delete(name);
} catch (err) {
core.error(`Failed to add ${name} label to PR #${issue_number}`);
core.debug(err);
}
}
async initialize() {
const { number, owner, repo } = import_github2.context.issue;
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)));
Expand Down