If we fail to apply the patch the tree is left in a dirty state
so reset to the last head. This avoids irritating errors like:
gbp:error: Failed to apply 'debian/patches/poison+remember_trash': Failed to commit tree: fatal: invalid date format: 1998/03/21
following files would be overwritten by checkout:
doc/hosts.nntp.5
innd/art.c
innd/innd.h
innd/rc.c
Please, commit your changes or stash them before you can switch branches.
Aborting
Thanks: Marco d'Itri for the repo to debug this
apply_and_commit_patch(repo, patch, maintainer, patch.topic)
except (GbpError, GitRepositoryError) as e:
gbp.log.err("Failed to apply '%s': %s" % (patch.path, e))
+ repo.force_head('HEAD', hard=True)
repo.set_branch(branch)
repo.delete_branch(pq_branch)
break