-
Notifications
You must be signed in to change notification settings - Fork 0
fix(docs): verify future release tag against candidate source #724
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -125,6 +125,27 @@ function gitObjectExists(repoRoot, object, gitCommand) { | |
| ); | ||
| } | ||
|
|
||
| export function candidateTagFromValidationOutput(output) { | ||
| const match = /^validated .+: [A-Za-z0-9][A-Za-z0-9._-]{0,63} (\d+\.\d+\.\d+)\s*$/.exec( | ||
| output, | ||
| ); | ||
| return match ? `v${match[1]}` : undefined; | ||
| } | ||
|
|
||
| function currentReleaseCandidateTag(repoRoot) { | ||
| const validator = resolve(repoRoot, 'release/scripts/registry-release'); | ||
| const result = spawnSync(validator, ['validate-current'], { | ||
| cwd: repoRoot, | ||
| encoding: 'utf8', | ||
| env: { ...process.env, GIT_NO_LAZY_FETCH: '1' }, | ||
| stdio: 'pipe', | ||
| }); | ||
| if (result.status !== 0) { | ||
| return undefined; | ||
| } | ||
| return candidateTagFromValidationOutput(result.stdout); | ||
| } | ||
|
|
||
| function safePathParts(parts) { | ||
| try { | ||
| return parts.map((part) => decodeURIComponent(part)); | ||
|
|
@@ -148,7 +169,12 @@ function validRepositoryPath(parts) { | |
| ); | ||
| } | ||
|
|
||
| function checkRepositoryEvidence(repoRoot, rawUrl, gitCommand) { | ||
| function checkRepositoryEvidence( | ||
| repoRoot, | ||
| rawUrl, | ||
| gitCommand, | ||
| { candidateTag, sourceRef } = {}, | ||
| ) { | ||
| let url; | ||
| try { | ||
| url = new URL(rawUrl); | ||
|
|
@@ -189,7 +215,10 @@ function checkRepositoryEvidence(repoRoot, rawUrl, gitCommand) { | |
| } | ||
|
|
||
| if (!gitObjectExists(repoRoot, `${commitish}^{commit}`, gitCommand)) { | ||
| return `references missing Git commit or tag ${ref}`; | ||
| if (ref !== candidateTag || !gitObjectExists(repoRoot, `${sourceRef}^{commit}`, gitCommand)) { | ||
| return `references missing Git commit or tag ${ref}`; | ||
| } | ||
| commitish = sourceRef; | ||
|
Comment on lines
217
to
+221
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the candidate ref exists but cannot peel to a commit, such as when AGENTS.md reference: docs/site/AGENTS.md:L25-L28 Useful? React with 👍 / 👎. |
||
| } | ||
| const path = repositoryPath.join('/'); | ||
| if (!gitObjectExists(repoRoot, `${commitish}^{commit}:${path}`, gitCommand)) { | ||
|
|
@@ -244,6 +273,7 @@ export function checkEvidenceLinks({ | |
| dataDir = resolve(scriptDir, '../src/data'), | ||
| sourceRef = 'HEAD', | ||
| gitCommand = 'git', | ||
| candidateTag, | ||
| } = {}) { | ||
| const errors = []; | ||
| let evidence; | ||
|
|
@@ -256,7 +286,7 @@ export function checkEvidenceLinks({ | |
| for (const item of evidence) { | ||
| const error = item.url.startsWith('/') | ||
| ? checkCurrentDocsEvidence(repoRoot, sourceRef, item.url, gitCommand) | ||
| : checkRepositoryEvidence(repoRoot, item.url, gitCommand); | ||
| : checkRepositoryEvidence(repoRoot, item.url, gitCommand, { candidateTag, sourceRef }); | ||
| if (error) { | ||
| errors.push(`${item.location}: ${item.url}: ${error}`); | ||
| } | ||
|
|
@@ -276,7 +306,10 @@ function sourceRefArgument(args) { | |
|
|
||
| if (process.argv[1] && resolve(process.argv[1]) === scriptPath) { | ||
| try { | ||
| const result = checkEvidenceLinks({ sourceRef: sourceRefArgument(process.argv.slice(2)) }); | ||
| const repoRoot = resolve(scriptDir, '../../..'); | ||
| const sourceRef = sourceRefArgument(process.argv.slice(2)); | ||
| const candidateTag = currentReleaseCandidateTag(repoRoot); | ||
| const result = checkEvidenceLinks({ repoRoot, sourceRef, candidateTag }); | ||
| if (result.errors.length > 0) { | ||
| console.error('Evidence link check failed:'); | ||
| for (const error of result.errors) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reviewed commit message has no
Signed-off-by:trailer, so it violates the repository's mandatory DCO policy and will be rejected by the DCO gate; recreate the commit withgit commit -s.AGENTS.md reference: AGENTS.md:L274-L274
Useful? React with 👍 / 👎.