Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 22 additions & 0 deletions .github/scripts/__tests__/source-context.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,28 @@ test('dependency repair promotion marker supplies explicit dependency source con
assert.equal(context.requiresIssue, false);
});

test('dependency repair promotion marker suppresses incidental issue references', () => {
const marker = [
'<!-- dependency-repair-promotion:v1 ',
JSON.stringify({
source_pr: 2795,
source_base_sha: 'a'.repeat(40),
source_head_sha: 'b'.repeat(40),
promotion_base_sha: 'c'.repeat(40),
}),
' -->',
].join('');
const context = resolvePrSourceContext({
body: `${marker}\nFixes #99`,
head: { ref: 'agent/deps-repair-2795' },
});

assert.equal(context.sourceType, SOURCE_TYPES.DEPENDABOT);
assert.equal(context.issueNumber, null);
assert.equal(context.sourceRef, 'dependency-pr:#2795');
assert.equal(context.requiresIssue, false);
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

test('malformed dependency repair promotion marker does not authorize source context', () => {
const context = resolvePrSourceContext({
body: '<!-- dependency-repair-promotion:v1 {"source_pr":2795} -->',
Expand Down
5 changes: 4 additions & 1 deletion .github/scripts/source_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ function resolvePrSourceContext(pull = {}) {
const body = String(pull?.body || '');
const block = parseWorkflowSourceBlock(body);
const dependencyRepairPromotion = parseDependencyRepairPromotionSource(body);
const issueNumber = extractIssueNumberFromPull(pull);
const extractedIssueNumber = extractIssueNumberFromPull(pull);
// Promotion provenance is authoritative: a coincidental issue reference must
// not route the PR through issue-body synchronization.
const issueNumber = dependencyRepairPromotion ? null : extractedIssueNumber;
Comment thread
stranske marked this conversation as resolved.
Resolved
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
const noAutomation = hasNoAutomationWorkflowContext(pull);

const markerType = normalizeSourceType(parseHtmlMarker(body, 'workflow-source'));
Expand Down
5 changes: 4 additions & 1 deletion templates/consumer-repo/.github/scripts/source_context.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ function resolvePrSourceContext(pull = {}) {
const body = String(pull?.body || '');
const block = parseWorkflowSourceBlock(body);
const dependencyRepairPromotion = parseDependencyRepairPromotionSource(body);
const issueNumber = extractIssueNumberFromPull(pull);
const extractedIssueNumber = extractIssueNumberFromPull(pull);
// Promotion provenance is authoritative: a coincidental issue reference must
// not route the PR through issue-body synchronization.
const issueNumber = dependencyRepairPromotion ? null : extractedIssueNumber;
const noAutomation = hasNoAutomationWorkflowContext(pull);

const markerType = normalizeSourceType(parseHtmlMarker(body, 'workflow-source'));
Expand Down
Loading