Rfaulk has submitted this change and it was merged.
Change subject: mod - cleanup sync logic, rm .deploy file - not needed.
......................................................................
mod - cleanup sync logic, rm .deploy file - not needed.
Change-Id: I965460a3167436020b338754694c8a837aac0045
---
M sartoris/sartoris.py
1 file changed, 30 insertions(+), 17 deletions(-)
Approvals:
Rfaulk: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/sartoris/sartoris.py b/sartoris/sartoris.py
index 53b9b2f..8d9c29a 100755
--- a/sartoris/sartoris.py
+++ b/sartoris/sartoris.py
@@ -70,6 +70,9 @@
# Default tag message
DEFAULT_TAG_MSG = 'Sartoris Tag.'
+ # Default tag message
+ DEFAULT_COMMIT_MSG = 'Sartoris Commit .'
+
# class instance
__instance = None
@@ -205,6 +208,31 @@
_repo.object_store.add_object(tag_obj)
_repo['refs/tags/' + tag] = tag_obj.id
+ def _dulwich_commit(self, tag, author, message=DEFAULT_COMMIT_MSG):
+ """
+ Creates a tag in git via dulwich calls:
+
+ Parameters:
+ tag - string :: "<project>-[start|sync]-<timestamp>"
+ author - string :: "Your Name <[email protected]>"
+ """
+
+ # Open the repo
+ _repo = Repo(self.config['top_dir'])
+
+ # 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]
+
+ # Add tag to the object store
+ _repo.object_store.add_object(tag_obj)
+ _repo['refs/tags/' + tag] = tag_obj.id
+
def _make_tag(self):
timestamp = datetime.now().strftime(self.DATE_TIME_TAG_FORMAT)
return '{0}-{1}'.format(self.config['user'], timestamp)
@@ -255,30 +283,16 @@
self._remove_lock()
return 0
- def sync(self, args, no_deps=False, force=False):
+ def sync(self, args):
"""
* add a sync tag
* write a .deploy file with the tag information
* call a sync hook with the prefix (repo) and tag info
"""
- #TODO: do git calls in dulwich, rather than shelling out
if not self._check_lock():
- exit_code = 30
- log.error("{0} :: {1}".format(__name__, exit_codes[exit_code]))
- return exit_code
- repo_name = self.config['repo_name']
+ raise SartorisError(message=exit_codes[30], exit_code=30)
tag = self._make_tag()
-
- # Write .deploy file
- try:
- deploy_file = open(self.config['deploy_file'], 'w')
- deploy_file.write(json.dumps({'repo': repo_name, 'tag': tag}))
- deploy_file.close()
- except OSError:
- exit_code = 32
- log.error("{0} :: {1}".format(__name__, exit_codes[exit_code]))
- return exit_code
return self._sync(tag, args.force)
@@ -287,7 +301,6 @@
repo_name = self.config['repo_name']
sync_script = '{0}/{1}.sync'.format(self.config["sync_dir"], repo_name)
- #TODO: use a pluggable sync system rather than shelling out
if os.path.exists(sync_script):
log.info('{0} :: Calling sync script at {1}'.format(__name__,
sync_script))
--
To view, visit https://gerrit.wikimedia.org/r/86363
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I965460a3167436020b338754694c8a837aac0045
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