-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
submit: Fix outdated PR templates with lower-case names (#371)
We use the contents of possible PR template sites as the hash key for caching the PR templates we get from the remote. This was only looking at `PULL_REQUEST_TEMPLATE.md` names, even though `pull_request_template.md` is valid and accepted. This change ensures that lower-cased versions are also considered when calculating the hash key. To do this, we consider upper-case and lower-case variants of configured Forge template paths when calculating the cache key. Case-insensitivity of this path is considered part of the Forge contract because GitHub and GitLab both treat these as case-insensitive-ish. We can adjust this assumption if we add a forge that doesn't. Resolves #369
- Loading branch information
Showing
4 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
kind: Fixed | ||
body: 'github: Fix outdated PR templates being used when templates used lower-cased file names.' | ||
time: 2024-08-29T20:43:53.225092-07:00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
testdata/script/issue369_branch_submit_pr_template_cache_case_insensitive.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# 'branch submit' invalidates template cache when a template is changed, | ||
# and it has a lower-cased name. | ||
# | ||
# https://github.com/abhinav/git-spice/issues/369 | ||
|
||
as 'Test <[email protected]>' | ||
at '2024-08-29T20:21:22Z' | ||
|
||
# setup | ||
cd repo | ||
git init | ||
git add .shamhub | ||
git commit -m 'Initial commit' | ||
|
||
# set up a fake remote | ||
shamhub init | ||
shamhub new origin alice/example.git | ||
shamhub register alice | ||
git push origin main | ||
|
||
env SHAMHUB_USERNAME=alice | ||
gs auth login | ||
|
||
# Submit a PR with the first template. | ||
git add feature1.txt | ||
gs bc -m feature1 | ||
gs branch submit --fill | ||
|
||
# Push a new template | ||
gs trunk | ||
mv $WORK/extra/change_template.md .shamhub/change_template.md | ||
git add .shamhub/change_template.md | ||
git commit -m 'Change the template' | ||
git push origin main | ||
|
||
# Create a new PR with the new template. | ||
git add feature2.txt | ||
gs bc -m feature2 | ||
gs branch submit --fill | ||
|
||
shamhub dump changes | ||
cmpenv stdout $WORK/golden/pulls.json | ||
|
||
-- repo/.shamhub/change_template.md -- | ||
This is the first template. | ||
|
||
-- extra/change_template.md -- | ||
This is the second template. | ||
|
||
-- repo/feature1.txt -- | ||
feature 1 | ||
|
||
-- repo/feature2.txt -- | ||
feature 2 | ||
|
||
-- golden/pulls.json -- | ||
[ | ||
{ | ||
"number": 1, | ||
"html_url": "$SHAMHUB_URL/alice/example/change/1", | ||
"state": "open", | ||
"title": "feature1", | ||
"body": "\n\nThis is the first template.\n", | ||
"base": { | ||
"ref": "main", | ||
"sha": "2036762c8e15b28b80f94f5085db6d4d1f2678e8" | ||
}, | ||
"head": { | ||
"ref": "feature1", | ||
"sha": "56594727085e14b4c394420451042c322eaf9441" | ||
} | ||
}, | ||
{ | ||
"number": 2, | ||
"html_url": "$SHAMHUB_URL/alice/example/change/2", | ||
"state": "open", | ||
"title": "feature2", | ||
"body": "\n\nThis is the second template.\n", | ||
"base": { | ||
"ref": "main", | ||
"sha": "2036762c8e15b28b80f94f5085db6d4d1f2678e8" | ||
}, | ||
"head": { | ||
"ref": "feature2", | ||
"sha": "91537b46b0c34e9df135cebe1e9270d5d7627952" | ||
} | ||
} | ||
] |