Skip to content

Commit 22e1b3c

Browse files
committed
Fix links to template repo in PRs
1 parent 5591df0 commit 22e1b3c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎.github/workflows/centralised_cruft_updater.yml‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,17 @@ jobs:
219219
if: steps.cruft_json.outputs.has_changes == '1'
220220
env:
221221
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
222+
TEMPLATE_REPO: ${{ github.repository }}
222223
OLD_COMMIT: ${{ steps.cruft_update.outputs.old_commit }}
223224
NEW_COMMIT: ${{ steps.cruft_update.outputs.new_commit }}
224225
run: |
225226
COMMIT_LOG=""
226227
if [ -n "$OLD_COMMIT" ] && [ -n "$NEW_COMMIT" ] && [ "$OLD_COMMIT" != "$NEW_COMMIT" ]; then
227-
COMMIT_LOG=$(gh api "repos/${{ github.repository }}/compare/${OLD_COMMIT}...${NEW_COMMIT}" \
228-
--jq '.commits[] | "- [" + .sha[0:7] + "](" + .html_url + ") " + (.commit.message | split("\n")[0])' 2>/dev/null || echo "")
228+
# A bare #123 in a template commit message refers to the template
229+
# repo, but would render as a link to the package repo when posted
230+
# in a PR body, so qualify each reference with the template repo.
231+
COMMIT_LOG=$(gh api "repos/${TEMPLATE_REPO}/compare/${OLD_COMMIT}...${NEW_COMMIT}" \
232+
--jq '.commits[] | "- [" + .sha[0:7] + "](" + .html_url + ") " + (.commit.message | split("\n")[0] | gsub("(?<![\\w/#])#(?<n>[0-9]+)"; env.TEMPLATE_REPO + "#" + .n))' 2>/dev/null || echo "")
229233
fi
230234
231235
{

0 commit comments

Comments
 (0)