Skip to content

Commit 8642a2b

Browse files
committed
unknown-words: Suggest merging
When someone creates a PR to a branch with check-spelling and their head branch doesn't have check-spelling, the metadata update can't happen on their head branch, so instead the instructions are to update the metadata branch. In order to make this make sense and be useful / helpful, the branch with the updated metadata must be merged into the head branch.
1 parent 07144bb commit 8642a2b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

unknown-words.sh

+14
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,7 @@ spelling_body() {
26432643
26442644
$B sh
26452645
$err
2646+
$(generate_merge_instructions "git commit -m 'updating check-spelling metadata' && " "")
26462647
$B
26472648
</details>
26482649
" | strip_lead)"
@@ -2885,6 +2886,18 @@ add_talk_to_bot_message() {
28852886
fi
28862887
}
28872888

2889+
escape_git_branch() {
2890+
echo "$1" | perl -pe "s/'/$q$Q$q$Q$q/g"
2891+
}
2892+
2893+
generate_merge_instructions() {
2894+
text_before="$1"
2895+
text_after="$2"
2896+
if [ -n "$GITHUB_HEAD_REF" ] && [ "$remote_ref" != "$GITHUB_HEAD_REF" ]; then
2897+
echo "${text_before}git checkout '$(escape_git_branch "$GITHUB_HEAD_REF")' && git merge '$(escape_git_branch "$remote_ref")'${text_after}"
2898+
fi
2899+
}
2900+
28882901
generate_sample_commit_help() {
28892902
if [ ! -s "$tokens_file" ]; then
28902903
return
@@ -2939,6 +2952,7 @@ generate_sample_commit_help() {
29392952
echo "git am <<'$delim'"
29402953
cat "$git_apply_commit"
29412954
echo "$delim$n$B$N"
2955+
generate_merge_instructions "$b" "$b"
29422956
echo 'And `git push` ...'
29432957
echo "</details>$N**OR**$N"
29442958
else

0 commit comments

Comments
 (0)