From f474ae0f4bd808618610fdc97a212eea3831b4e7 Mon Sep 17 00:00:00 2001 From: Dennis Kliban Date: Mon, 12 Jul 2021 11:59:52 -0400 Subject: [PATCH] Handle conflict when cherry-picking changelog fixes: #439 --- CHANGES/439.bugfix | 1 + .../workflows/scripts/stage-changelog-for-master.py.j2 | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 CHANGES/439.bugfix diff --git a/CHANGES/439.bugfix b/CHANGES/439.bugfix new file mode 100644 index 00000000..709fec82 --- /dev/null +++ b/CHANGES/439.bugfix @@ -0,0 +1 @@ +Handle conflicts when cherry-picking changelog to master branch. diff --git a/templates/github/.github/workflows/scripts/stage-changelog-for-master.py.j2 b/templates/github/.github/workflows/scripts/stage-changelog-for-master.py.j2 index f235910b..2fd58881 100644 --- a/templates/github/.github/workflows/scripts/stage-changelog-for-master.py.j2 +++ b/templates/github/.github/workflows/scripts/stage-changelog-for-master.py.j2 @@ -5,6 +5,7 @@ import os import textwrap from git import Repo +from git.exc import GitCommandError helper = textwrap.dedent( @@ -48,5 +49,11 @@ if not changelog_commit: git = repo.git git.stash() git.checkout("origin/master") -git.cherry_pick(changelog_commit.hexsha) +try: + git.cherry_pick(changelog_commit.hexsha) +except GitCommandError: + git.add("CHANGES/") + # Don't try opening an editor for the commit message + with git.custom_environment(GIT_EDITOR='true'): + git.cherry_pick("--continue") git.reset("origin/master")