Rfaulk has uploaded a new change for review.

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


Change subject: add - methods _dulwich_stage & _dulwich_commit.
......................................................................

add - methods _dulwich_stage & _dulwich_commit.

Change-Id: I66e457b764fc41aa462e1c4ac66f563ce4a9b353
---
M sartoris/sartoris.py
1 file changed, 12 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/sartoris refs/changes/67/86367/1

diff --git a/sartoris/sartoris.py b/sartoris/sartoris.py
index 8d9c29a..02f4ed1 100755
--- a/sartoris/sartoris.py
+++ b/sartoris/sartoris.py
@@ -17,7 +17,6 @@
 import socket
 from re import search
 import subprocess
-import json
 from time import time
 from datetime import datetime
 
@@ -71,7 +70,7 @@
     DEFAULT_TAG_MSG = 'Sartoris Tag.'
 
     # Default tag message
-    DEFAULT_COMMIT_MSG = 'Sartoris Commit .'
+    DEFAULT_COMMIT_MSG = 'Sartoris Commit'
 
     # class instance
     __instance = None
@@ -208,30 +207,22 @@
         _repo.object_store.add_object(tag_obj)
         _repo['refs/tags/' + tag] = tag_obj.id
 
-    def _dulwich_commit(self, tag, author, message=DEFAULT_COMMIT_MSG):
+    def _dulwich_stage(self, file):
         """
-        Creates a tag in git via dulwich calls:
-
-        Parameters:
-            tag - string :: "<project>-[start|sync]-<timestamp>"
-            author - string :: "Your Name <[email protected]>"
+        Stage modified files in the repo
         """
-
-        # Open the repo
         _repo = Repo(self.config['top_dir'])
+        _repo.stage([file])
 
-        # Create the tag object
-        tag_obj = Tag()
-        tag_obj.tagger = author
-        tag_obj.message = message
-        tag_obj.name = tag
-        tag_obj.object = (Commit, _repo.refs['HEAD'])
-        tag_obj.tag_time = int(time())
-        tag_obj.tag_timezone = parse_timezone('-0200')[0]
+    def _dulwich_commit(self, author, message=DEFAULT_COMMIT_MSG):
+        """
+        Commit staged files in the repo
+        """
+        _repo = Repo(self.config['top_dir'])
+        commit_id = _repo.do_commit(message, committer=author)
 
-        # Add tag to the object store
-        _repo.object_store.add_object(tag_obj)
-        _repo['refs/tags/' + tag] = tag_obj.id
+        if not _repo.head() == commit_id:
+            raise SartorisError(message=exit_codes[14], exit_code=14)
 
     def _make_tag(self):
         timestamp = datetime.now().strftime(self.DATE_TIME_TAG_FORMAT)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I66e457b764fc41aa462e1c4ac66f563ce4a9b353
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