@@ -81,6 +81,7 @@ LANGS[sv_SE]="Swedish"
8181LANGS[zh_CN]=" Simplified Chinese"
8282
8383find_or_add_missing_entries () {
84+ local branch=${1:- main}
8485 local changelog
8586 changelog=$( sed -rne ' /^###.*' " ${target_release// ./ \. } " ' \b/,/^### ' " ${prev_release// ./ \. } " ' \b/p' ChangeLog)
8687 local changelog_begin_position
@@ -91,19 +92,19 @@ find_or_add_missing_entries() {
9192 check_or_add_pr " $id "
9293 done
9394
94- local target_ref=origin/main
95+ local target_ref=origin/${branch}
9596 if git tag | grep -qxF " ${target_release_tag} " ; then
9697 # already released, use this
9798 target_ref=" ${target_release_tag} "
9899 fi
99100 echo
100101 echo " Checking if all PR references in git log since ${prev_release_tag} are included for ${target_release} based on ref ${target_ref} ..."
101102 local milestone
102- for id in $( git log " ${prev_release_tag} ..main " | grep -oP ' #\K(\d+)' ) ; do
103+ for id in $( git log " ${prev_release_tag} ..${target_ref} " | grep -oP ' #\K(\d+)' ) ; do
103104 gh pr view " ${id} " --json title & > /dev/null || continue # Skip non-PRs
104105 milestone=$( gh pr view " ${id} " --json milestone --jq .milestone.title)
105106 if [[ " ${milestone} " =~ " Release " ]] && [[ " ${milestone} " != " Release ${target_release} " ]]; then
106- echo " -> Ignoring PR #${id} , which was mentioned in 'git log ${prev_release_tag} ..HEAD ', but already has milestone '${milestone} '"
107+ echo " -> Ignoring PR #${id} , which was mentioned in 'git log ${prev_release_tag} ..${target_ref} ', but already has milestone '${milestone} '"
107108 continue
108109 fi
109110 check_or_add_pr " ${id} "
@@ -337,30 +338,58 @@ sanitize_title() {
337338 -re ' s/\b((Add)|(Updat|Enhanc|Improv|Remov)e)\b/\2\3ed/i'
338339}
339340
340- case " ${1:- 1} " in
341- find-missing-entries)
342- ACTION=find-missing-entries
343- ;;
344- add-missing-entries)
345- ACTION=add-missing-entries
346- ;;
347- group-entries)
348- ACTION=group-entries
349- ;;
350- --help)
351- echo " Usage: $0 ACTION"
352- echo " Supported actions:"
353- echo " * find-missing-entries: Prints a list"
354- echo " * add-missing-entries: Inserts missing entries into the file"
355- echo " * group-entries: Groups existing entries by prefix"
356- echo
357- exit
358- ;;
359- * )
360- echo " ERROR: Bad invocation, see --help"
341+ branch=main
342+ ACTION=" "
343+
344+ set_action () {
345+ local new_action=" ${1} "
346+ if [[ -n " ${ACTION} " ]]; then
347+ echo " ERROR: Only one ACTION may be specified (got '${ACTION} ' and '${new_action} ')"
361348 exit 1
362- ;;
363- esac
349+ fi
350+ ACTION=" ${new_action} "
351+ }
352+
353+ while true ; do
354+ case " ${1:- } " in
355+ find-missing-entries)
356+ set_action find-missing-entries
357+ shift
358+ ;;
359+ add-missing-entries)
360+ set_action add-missing-entries
361+ shift
362+ ;;
363+ group-entries)
364+ set_action group-entries
365+ shift
366+ ;;
367+ --branch)
368+ shift
369+ [[ -z " ${1:- } " ]] && echo " ERROR: Missing argument for --branch" && exit 1
370+ branch=" ${1} "
371+ shift
372+ ;;
373+ --help)
374+ echo " Usage: $0 [--branch branch-name] ACTION"
375+ echo " Supported actions:"
376+ echo " * find-missing-entries: Prints a list"
377+ echo " * add-missing-entries: Inserts missing entries into the file"
378+ echo " * group-entries: Groups existing entries by prefix"
379+ echo
380+ echo " Options:"
381+ echo " --branch branch-name: Specify the branch to check (default: main)"
382+ echo " This option ensures only PRs merged into the specified branch are considered."
383+ echo
384+ exit
385+ ;;
386+ * )
387+ [[ -n " ${ACTION} " && $# -eq 0 ]] && break
388+ echo " ERROR: Bad invocation, see --help"
389+ exit 1
390+ ;;
391+ esac
392+ done
364393
365394target_release=$( grep -oP ' ^### .*\K(\d+\.\d+\.\d+)\b' ChangeLog | head -n1)
366395prev_release=$( grep -oP ' ^### .*\K(\d+\.\d+\.\d+)\b' ChangeLog | head -n2 | tail -n1)
373402
374403case " $ACTION " in
375404 find-missing-entries | add-missing-entries)
376- find_or_add_missing_entries
405+ find_or_add_missing_entries " ${branch} "
377406 ;;
378407 group-entries)
379408 group_entries
0 commit comments