File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -613,12 +613,29 @@ add_change_id() {
613613 }
614614 changeIdAfter = "^(" tolower("' " $CHANGE_ID_AFTER " ' ") "):"
615615 numlines = split(lines, footer, "\n")
616+
617+ # Find the last line that starts with a comment character.
618+ coauthorIndex = 0
619+ for (line = 1; line <= numlines; line++) {
620+ if (match(tolower(footer[line]), /^co-authored-by:/)) {
621+ coauthorIndex = line
622+ }
623+ }
624+
616625 for (line = 1; line <= numlines; line++) {
617626 if (unprinted && match(tolower(footer[line]), changeIdAfter) != 1) {
618- unprinted = 0
619- print "Change-Id: I' " $id " ' "
627+ # If the Change-Id is the first line in the footer, print it first.
628+ if (coauthorIndex == 0 || line > coauthorIndex) {
629+ print "Change-Id: I' " $id " ' "
630+ unprinted = 0
631+ }
620632 }
621633 print footer[line]
634+
635+ if(line == coauthorIndex && unprinted) {
636+ print "Change-Id: I' " $id " ' "
637+ unprinted = 0
638+ }
622639 }
623640 if (unprinted) {
624641 print "Change-Id: I' " $id " ' "
You can’t perform that action at this time.
0 commit comments