|
49 | 49 | const TRAILER = /Companion:\s*(?:https?:\/\/github\.com\/)?([\w.-]+)\/([\w.-]+)(?:\/pull\/|#)(\d+)/gi; |
50 | 50 | const REF = /(?:https?:\/\/github\.com\/)?([\w.-]+)\/([\w.-]+)(?:\/pull\/|#)(\d+)/g; |
51 | 51 | const { owner, repo } = context.repo; |
| 52 | + // Directional label: copilot/mothership PRs get "requires-sim-merge", |
| 53 | + // sim PRs get "requires-mothership-merge". Applied whenever the PR |
| 54 | + // declares a companion; removed when it declares none. |
| 55 | + const otherSide = repo === 'sim' ? 'mothership/copilot' : 'sim'; |
| 56 | + const LABEL = repo === 'sim' ? 'requires-mothership-merge' : 'requires-sim-merge'; |
| 57 | + const LABEL_DESC = `Has a companion PR on the ${otherSide} side — merge in lockstep`; |
52 | 58 | const crossToken = process.env.CROSS_REPO_TOKEN; |
53 | 59 | // Read the OTHER repo's PR via a plain REST fetch with the PAT in the |
54 | 60 | // header — keeps the PAT strictly READ-ONLY and avoids re-instantiating |
@@ -108,17 +114,14 @@ jobs: |
108 | 114 | const ex = await findSticky(prNumber); |
109 | 115 | if (ex) await github.rest.issues.deleteComment({ owner, repo, comment_id: ex.id }); |
110 | 116 | // Drop the label too, so a PR edited to remove all companions doesn't |
111 | | - // keep a stale has-companion badge. 404 if not present → ignore. |
112 | | - try { await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: 'has-companion' }); } catch {} |
| 117 | + // keep a stale badge. 404 if not present → ignore. |
| 118 | + try { await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: LABEL }); } catch {} |
113 | 119 | } |
114 | 120 | async function ensureLabel() { |
115 | | - try { await github.rest.issues.getLabel({ owner, repo, name: 'has-companion' }); } |
| 121 | + try { await github.rest.issues.getLabel({ owner, repo, name: LABEL }); } |
116 | 122 | catch { |
117 | 123 | try { |
118 | | - await github.rest.issues.createLabel({ |
119 | | - owner, repo, name: 'has-companion', color: '5319e7', |
120 | | - description: 'Has a cross-repo companion PR (see companion-pr-check)', |
121 | | - }); |
| 124 | + await github.rest.issues.createLabel({ owner, repo, name: LABEL, color: 'd93f0b', description: LABEL_DESC }); |
122 | 125 | } catch {} |
123 | 126 | } |
124 | 127 | } |
@@ -162,7 +165,7 @@ jobs: |
162 | 165 | const companions = await collectCompanions(pr); |
163 | 166 | if (companions.length === 0) { await clear(pr.number); return; } |
164 | 167 | await ensureLabel(); |
165 | | - try { await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ['has-companion'] }); } catch {} |
| 168 | + try { await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: [LABEL] }); } catch {} |
166 | 169 |
|
167 | 170 | const base = pr.base.ref; |
168 | 171 | const lines = []; |
|
0 commit comments