Skip to content

Commit

Permalink
propagate existing coauthor information (handles repeated squash call…
Browse files Browse the repository at this point in the history
…s etc.)
  • Loading branch information
kpedro88 committed Oct 13, 2023
1 parent 1409395 commit 247f3dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion git-cms-merge-topic
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,14 @@ if [ "$NOMERGE" = "true" ]; then
elif [ "$COMMAND_NAME" = "cms-squash-topic" ]; then
# save the list of authors
SQUASH_AUTHOR="$(git config --get user.name) <$(git config --get user.email)>"
readarray -t COAUTHORS < <(git log $MERGE_BASE_BRANCH..$FULL_BRANCH --format="%an <%ae>" | sort -u | grep -v "$SQUASH_AUTHOR")
# git log w/ specified format prints:
# Co-authored-by: Author <email>
# commit raw subject + body (which might also contain Co-authored-by lines, possibly indented)
# sed -n suppresses printouts by default
# then selects lines matching: any number of spaces + "Co-authored-by: " (which is then removed)
# i = case-insensitive, p = print
# finally, sort removes duplicates, and grep removes the current user (who will already be the author of the squash commit)
readarray -t COAUTHORS < <(git log $MERGE_BASE_BRANCH..$FULL_BRANCH --format="Co-Authored-by: %an <%ae>\n%B" | sed -n 's/^ *Co-authored-by: //ip' | sort -u | grep -v "$SQUASH_AUTHOR")
# by default, automatically populate commit message
git reset --hard $MERGE_BASE
git merge --squash "HEAD@{1}"
Expand Down

0 comments on commit 247f3dc

Please sign in to comment.