Rfaulk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/86359


Change subject: add - new revert logic.
......................................................................

add - new revert logic.

Change-Id: If0f0b6fed11f92298b0f584a06119ed9608f37ab
---
M sartoris/sartoris.py
1 file changed, 28 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/sartoris refs/changes/59/86359/1

diff --git a/sartoris/sartoris.py b/sartoris/sartoris.py
index 4858aa4..26a5093 100755
--- a/sartoris/sartoris.py
+++ b/sartoris/sartoris.py
@@ -413,26 +413,46 @@
     def revert(self, args):
         """
             * write a lock file
-            * write previous deploy info into .deploy
             * call sync hook with the prefix (repo) and tag info
-            * remove lock file
         """
 
         #TODO: do git calls in dulwich, rather than shelling out
         if not self._check_lock():
             raise SartorisError(message=exit_codes[30])
 
-        tag = self._make_tag()
+        revert_tag = self._make_tag()
 
-        # Perform revert
+        # Extract tag on which to revert
         if hasattr(args, 'tag'):
-            # revert to tag
-            pass
+            tag = args.tag
         else:
             # revert to last tag
-            pass
+            raise NotImplementedError()
 
-        self._sync(tag, args.force)
+        reset_cmd = 'git reset {0}'.format(tag)
+        add_cmd = 'git add *'
+        commit_cmd = 'git commit -m "revert to \'{0}\'"'.format(tag)
+
+        # Reset the HEAD
+        proc = subprocess.Popen(reset_cmd.split(),
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE)
+        proc.communicate()
+
+        # Add changes to staging
+        proc = subprocess.Popen(add_cmd.split(),
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE)
+        proc.communicate()
+
+        # Commit
+        proc = subprocess.Popen(commit_cmd.split(),
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE)
+        proc.communicate()
+
+        # Sync to reset HEAD
+        self._sync(revert_tag, args.force)
 
         return 0
 

-- 
To view, visit https://gerrit.wikimedia.org/r/86359
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If0f0b6fed11f92298b0f584a06119ed9608f37ab
Gerrit-PatchSet: 1
Gerrit-Project: sartoris
Gerrit-Branch: master
Gerrit-Owner: Rfaulk <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to