Skip to content

Commit 42335bf

Browse files
authored
fix(git): improve cherry-pick abort handling
1 parent 7e5b583 commit 42335bf

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

weblate/addons/git.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,15 @@ def squash_author(self, component: Component, repository: GitRepository) -> None
213213
base = repository.get_last_revision()
214214
# Cherry pick current commit (this should work
215215
# unless something is messed up)
216-
repository.execute(
217-
["cherry-pick", commit, *gpg_sign],
218-
environment={"WEBLATE_MERGE_SKIP": "1"},
219-
)
216+
try:
217+
repository.execute(
218+
["cherry-pick", commit, *gpg_sign],
219+
environment={"WEBLATE_MERGE_SKIP": "1"},
220+
)
221+
except RepositoryError:
222+
if repository.has_git_file("CHERRY_HEAD"):
223+
repository.execute(["cherry-pick", "--abort"])
224+
raise
220225
handled = []
221226
# Pick other commits by same author
222227
for i, other in enumerate(commits):
@@ -231,7 +236,8 @@ def squash_author(self, component: Component, repository: GitRepository) -> None
231236
except RepositoryError:
232237
# If fails, continue to another author, we will
233238
# pick this commit later (it depends on some other)
234-
repository.execute(["cherry-pick", "--abort"])
239+
if repository.has_git_file("CHERRY_HEAD"):
240+
repository.execute(["cherry-pick", "--abort"])
235241
break
236242
# Remove processed commits from list
237243
for i in reversed(handled):

0 commit comments

Comments
 (0)