diff --git a/.github/workflows/proposal-numbering.yml b/.github/workflows/proposal-numbering.yml index 5de7e9c..91d94ac 100644 --- a/.github/workflows/proposal-numbering.yml +++ b/.github/workflows/proposal-numbering.yml @@ -99,42 +99,70 @@ jobs: const incorrectFilesRaw = '${{ steps.check.outputs.files }}'; const incorrectTitlesRaw = '${{ steps.check.outputs.titles }}'; + // Get all files that need fixing (union of incorrect filenames and incorrect titles) + const filesNeedingFix = new Set(); + if (incorrectFilesRaw) { + incorrectFilesRaw.split(',').forEach(f => filesNeedingFix.add(f.trim())); + } + if (incorrectTitlesRaw) { + incorrectTitlesRaw.split(',').forEach(f => filesNeedingFix.add(f.trim())); + } + const warnings = []; - // Check filename issues - if (incorrectFilesRaw) { - const filesList = incorrectFilesRaw.split(',').map(f => `- ${f}`).join('\n'); + if (filesNeedingFix.size > 0) { + const files = Array.from(filesNeedingFix); + const filesList = files.map(f => `- ${f}`).join('\n'); + warnings.push( - '**Incorrect filename:**', + '**Issues found:**', '', filesList, - '', - `**Expected naming:** ${expectedPrefix}<descriptive-name>.md`, - '', - `Rename your proposal file to use PR #${prNumber}:`, - '', - '```bash', - `git mv proposals/000-.md ${expectedPrefix}.md`, - '```' + '' ); - } - // Check title issues - if (incorrectTitlesRaw) { - const titlesList = incorrectTitlesRaw.split(',').map(f => `- ${f}`).join('\n'); - if (warnings.length > 0) warnings.push('', '---', ''); + // For each file, generate specific fix commands + files.forEach(file => { + const basename = file.replace('proposals/', ''); + // Strip leading numbers or placeholder prefixes to get the descriptive part + const descriptive = basename.replace(/^[0-9]{3}-/, '').replace(/^(xxx|nnn|000)-/, ''); + const expectedFilename = `proposals/${String(prNumber).padStart(3, '0')}-${descriptive}`; + + const needsRename = file !== expectedFilename; + const needsTitleUpdate = incorrectTitlesRaw && incorrectTitlesRaw.includes(file); + + if (needsRename || needsTitleUpdate) { + warnings.push( + `**Fix for ${file}:**`, + '', + '```bash' + ); + + if (needsRename) { + warnings.push(`git mv ${file} ${expectedFilename}`); + } + + if (needsTitleUpdate) { + const targetFile = needsRename ? expectedFilename : file; + warnings.push( + `# Update title: remove any old number prefix and add PR number`, + `sed -i.bak '0,/^# /{s/^# \\([0-9]\\{3\\}\\|xxx\\|nnn\\|000\\) - /# ${prNumber} - /; t; s/^# /# ${prNumber} - /}' ${targetFile} && rm ${targetFile}.bak`, + `git add ${targetFile}` + ); + } + + warnings.push( + `git commit -m "Rename proposal to use PR number ${prNumber}"`, + 'git push', + '```', + '' + ); + } + }); + warnings.push( - '**Incorrect title format:**', - '', - titlesList, - '', - `**Expected title format:** # ${prNumber} - <Your Title>`, - '', - `Update the H1 heading in your proposal to include the PR number:`, - '', - '```markdown', - `# ${prNumber} - My Feature Title`, - '```' + '**Note:** The commands above can be copied and pasted directly into your terminal. The sed command will automatically preserve your title text.', + '' ); } diff --git a/.gitignore b/.gitignore index 485dee6..fcb1f9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea +.claude/settings.local.json diff --git a/notify-open-prs.sh b/notify-open-prs.sh index d6a1af5..72e4986 100755 --- a/notify-open-prs.sh +++ b/notify-open-prs.sh @@ -12,14 +12,6 @@ set -e OPEN_PRS=(70 82 83 85 88 93 94 96 98 99 100 101 103) -COMMENT_BODY="Hi! We've updated the proposal numbering system to use PR numbers as proposal identifiers. - -**Action required:** Please rebase your PR on \`main\`. - -Once you push, the GitHub workflow will automatically check your proposal file naming and update this PR description with specific instructions if your file needs to be renamed. - -See [proposals/README.md](https://github.com/kroxylicious/design/blob/main/proposals/README.md) for the updated workflow." - echo "This script will comment on ${#OPEN_PRS[@]} open proposal PRs" echo "" read -p "Continue? (y/N) " -n 1 -r @@ -30,9 +22,44 @@ if [[ ! $REPLY =~ ^[Yy]$ ]]; then fi for pr in "${OPEN_PRS[@]}"; do - echo "Commenting on PR #$pr..." + echo "Processing PR #$pr..." + + # Get the proposal file(s) from this PR + PROPOSAL_FILES=$(gh pr view "$pr" --json files --jq '.files[].path' | grep '^proposals/.*\.md$' | grep -v 'proposals/README.md' | grep -v 'proposals/000-template.md' || true) + + if [ -z "$PROPOSAL_FILES" ]; then + echo " No proposal files found, skipping" + continue + fi + + # Get the first proposal file (should only be one) + PROPOSAL_FILE=$(echo "$PROPOSAL_FILES" | head -1) + CURRENT_FILENAME=$(basename "$PROPOSAL_FILE") + EXPECTED_FILENAME=$(printf "%03d-" "$pr")$(echo "$CURRENT_FILENAME" | sed 's/^[0-9]*-//' | sed 's/^[a-z]*-//') + + # Build PR-specific comment + COMMENT_BODY="Hi! We've updated the proposal numbering system to use PR numbers as proposal identifiers. + +**Action required:** Please rebase your PR on \`main\`. + +Once you rebase, you'll need to rename your proposal file and update the title: + +\`\`\`bash +git mv $PROPOSAL_FILE proposals/$EXPECTED_FILENAME +# Update title: remove any old number prefix and add PR number +sed -i.bak '0,/^# /{s/^# \\([0-9]\\{3\\}\\|xxx\\|nnn\\|000\\) - /# $pr - /; t; s/^# /# $pr - /}' proposals/$EXPECTED_FILENAME && rm proposals/$EXPECTED_FILENAME.bak +git add proposals/$EXPECTED_FILENAME +git commit -m \"Rename proposal to use PR number\" +git push +\`\`\` + +The GitHub workflow will automatically check your proposal file naming after you push and update this PR description if any corrections are still needed. + +See [proposals/README.md](https://github.com/kroxylicious/design/blob/main/proposals/README.md) for the updated workflow." + + echo " Commenting on PR #$pr (file: $CURRENT_FILENAME → $EXPECTED_FILENAME)..." gh pr comment "$pr" --body "$COMMENT_BODY" - echo "✓ PR #$pr notified" + echo " ✓ PR #$pr notified" sleep 2 # Be nice to the API done