Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Update PR size check workflow (#51948)
John D. Swanson8a467a595882
diff --git a/.github/workflows/pr-size-check.yml b/.github/workflows/pr-size-check.ymlindex 670a11587ea..940c619e0cf 100644--- a/.github/workflows/pr-size-check.yml+++ b/.github/workflows/pr-size-check.yml@@ -11,12 +11,9 @@name: PR Size Checkon:- pull_request_target:+ pull_request:types: [opened, synchronize]-permissions:- contents: read-jobs:check-size:if: github.repository_owner == 'zed-industries'@@ -74,15 +71,18 @@ jobs:}}- // Remove existing size labels, then apply the current one+ // Update size label only if the classification changedconst existingLabels = (await github.rest.issues.listLabelsOnIssue({owner: context.repo.owner,repo: context.repo.repo,issue_number: context.issue.number,})).data.map(l => l.name);- for (const label of existingLabels) {- if (label.startsWith('size/')) {+ const existingSizeLabels = existingLabels.filter(l => l.startsWith('size/'));+ const alreadyCorrect = existingSizeLabels.length === 1 && existingSizeLabels[0] === sizeLabel;++ if (!alreadyCorrect) {+ for (const label of existingSizeLabels) {await github.rest.issues.removeLabel({owner: context.repo.owner,repo: context.repo.repo,@@ -90,27 +90,27 @@ jobs:name: label,});}- }- // Create the label if it doesn't exist (ignore 422 = already exists)- try {- await github.rest.issues.createLabel({+ // Create the label if it doesn't exist (ignore 422 = already exists)+ try {+ await github.rest.issues.createLabel({+ owner: context.repo.owner,+ repo: context.repo.repo,+ name: sizeLabel,+ color: labelColor,+ });+ } catch (e) {+ if (e.status !== 422) throw e;+ }++ await github.rest.issues.addLabels({owner: context.repo.owner,repo: context.repo.repo,- name: sizeLabel,- color: labelColor,+ issue_number: context.issue.number,+ labels: [sizeLabel],});- } catch (e) {- if (e.status !== 422) throw e;}- await github.rest.issues.addLabels({- owner: context.repo.owner,- repo: context.repo.repo,- issue_number: context.issue.number,- labels: [sizeLabel],- });-// For large PRs (400+ LOC): auto-apply large-pr label and comment onceif (totalChanges >= 400) {// Auto-apply the large-pr label