Rfaulk has submitted this change and it was merged.
Change subject: mod - ensure that commit sha matches tag commit sha on rollback
/ make _dulwich_reset_to_tag default reset to HEAD.
......................................................................
mod - ensure that commit sha matches tag commit sha on rollback / make
_dulwich_reset_to_tag default reset to HEAD.
Change-Id: I0783f330e0c3bb6b30f6ee430e82fc967e0b5942
---
M sartoris/config.py
M sartoris/sartoris.py
2 files changed, 15 insertions(+), 4 deletions(-)
Approvals:
Rfaulk: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/sartoris/config.py b/sartoris/config.py
index e5d4c95..41524b8 100644
--- a/sartoris/config.py
+++ b/sartoris/config.py
@@ -56,6 +56,7 @@
32: 'Failed to write the .deploy file. Exiting.',
33: 'git revert failed. Exiting.',
34: 'git log failed. Exiting.',
+ 35: 'Revert failed, could not find tag. Exiting.',
40: 'Failed to run sync script. Exiting.',
50: 'Failed to read the .deploy file. Exiting.',
60: 'Invalid git deploy action. Exiting.',
diff --git a/sartoris/sartoris.py b/sartoris/sartoris.py
index 21b2a11..d46f382 100755
--- a/sartoris/sartoris.py
+++ b/sartoris/sartoris.py
@@ -208,14 +208,19 @@
_repo.object_store.add_object(tag_obj)
_repo['refs/tags/' + tag] = tag_obj.id
- def _dulwich_reset_to_tag(self, tag):
+ def _dulwich_reset_to_tag(self, tag=None):
"""
Resets the HEAD to the commit
"""
_repo = Repo(self.config['top_dir'])
+ if not tag:
+ sha = _repo.head()
+ else:
+ sha = self._get_commit_sha_for_tag(tag)
+
try:
- _repo.refs['HEAD'] = self._get_commit_sha_for_tag(tag)
+ _repo.refs['HEAD'] = sha
except AttributeError:
raise SartorisError(message=exit_codes[7], exit_code=7)
@@ -514,13 +519,18 @@
# 3. commit
#
tag_commit_sha = self._get_commit_sha_for_tag(tag)
+ commit_sha = None
for commit_sha in self._git_commit_list():
if commit_sha == tag_commit_sha:
break
self._git_revert(commit_sha)
- self._dulwich_commit(self._make_author(),
- message='Rollback to {0}.'.format(tag))
+ # Ensure the commit tag was matched
+ if commit_sha != tag_commit_sha or not commit_sha:
+ self._dulwich_reset_to_tag()
+ raise SartorisError(message=exit_codes[35], exit_code=35)
+ self._dulwich_commit(self._make_author(),
+ message='Rollback to {0}.'.format(revert_tag))
return 0
def release(self):
--
To view, visit https://gerrit.wikimedia.org/r/87660
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0783f330e0c3bb6b30f6ee430e82fc967e0b5942
Gerrit-PatchSet: 1
Gerrit-Project: sartoris
Gerrit-Branch: master
Gerrit-Owner: Rfaulk <[email protected]>
Gerrit-Reviewer: Rfaulk <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits