Merger: log non Git exceptions on merge

Some git merge commands fails for me with an AssertionError coming from
GitPython:

 AssertionError: len([
    "5a0a437ee9a6fd4b30484dfdc2455c83ea00a058\t\t'refs/changes/80/111180/1'
of ssh://gerrit.wikimedia.org:29418/mediawiki/core\n"]
   )
   != len([
     'Total 10 (delta 9), reused 10 (delta 9)',
     ' * branch refs/changes/80/111180/1 -> FETCH_HEAD'
   ])

Zuul.Merger explicitly log merge exceptions at debug level, though we
should only load GitCommandError exceptions and properly log other
exceptions (such as AssertionError).

Change-Id: Idca682c0920b9e6eac3f12cc05634dfe304a0305
This commit is contained in:
Antoine Musso 2014-02-04 14:16:18 +01:00 committed by James E. Blair
parent 4076e2b432
commit 5f53e600c9
1 changed files with 5 additions and 2 deletions

View File

@ -216,11 +216,14 @@ class Merger(object):
commit = repo.cherryPick(item['refspec'])
else:
raise Exception("Unsupported merge mode: %s" % mode)
except Exception:
# Log exceptions at debug level because they are
except git.GitCommandError:
# Log git exceptions at debug level because they are
# usually benign merge conflicts
self.log.debug("Unable to merge %s" % item, exc_info=True)
return None
except Exception:
self.log.exception("Exception while merging a change:")
return None
return commit