From 4829b6eba5be26b6e5ee504a6d09638ad77aa4e4 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 3 May 2015 21:49:03 +0300 Subject: Refactor git stuff into global functions --- jt | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/jt b/jt index cb73b6e..03580ec 100755 --- a/jt +++ b/jt @@ -84,6 +84,15 @@ class DraftsDirectory(object): return None +def commit_to_git(source_dir, pathnames): + cliapp.runcmd(['git', 'add'] + pathnames, cwd=source_dir) + cliapp.runcmd(['git', 'commit', '-m', 'Publish log entry'], cwd=source_dir) + + +def push_git(source_dir): + cliapp.runcmd(['git', 'push', 'origin', 'HEAD'], cwd=source_dir) + + class Command(object): def __init__(self, app): @@ -241,18 +250,10 @@ class FinishCommand(Command): os.rename(draft_attch, pub_attch) def _commit_to_git(self, pathnames): - cliapp.runcmd( - ['git', 'add'] + pathnames, - cwd=self._app.settings['source']) - - cliapp.runcmd( - ['git', 'commit', '-m', 'Publish log entry'], - cwd=self._app.settings['source']) + commit_to_git(self._app.settings['source'], pathnames) def _push_git(self): - cliapp.runcmd( - ['git', 'push', 'origin', 'HEAD'], - cwd=self._app.settings['source']) + push_git(self._app.settings['source']) class NewTopicCommand(Command): -- cgit v1.2.1