From 7910e7d7cdeae077c7c80f7618b8afb0b2f7c046 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 22 Nov 2014 19:22:48 +0200 Subject: Move git stuff into helper methods --- jt | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/jt b/jt index c1d292f..8e3cf02 100755 --- a/jt +++ b/jt @@ -175,17 +175,12 @@ class FinishCommand(Command): os.rename(draft_attch, pub_attch) if self._app.settings['git']: - argv = ['git', 'add', pub_mdwn] if os.path.exists(pub_attch): - argv.append(pub_attch) - cliapp.runcmd(argv, cwd=self._app.settings['source']) - cliapp.runcmd( - ['git', 'commit', '-m', 'Publish log entry'], - cwd=self._app.settings['source']) - if self.settings['push']: - cliapp.runcmd( - ['git', 'push', 'origin', 'HEAD'], - cwd=self._app.settings['source']) + self.commit_to_git([pub_mdwn, pub_attch]) + else: + self.commit_to_git([pub_mdwn]) + if self._app.settings['push']: + self.push_git() def published_dir(self): subdirs = { @@ -211,6 +206,20 @@ class FinishCommand(Command): return basename + def commit_to_git(self, pathnames): + cliapp.runcmd( + ['git', 'add'] + pathname, + cwd=self._app.settings['source']) + + cliapp.runcmd( + ['git', 'commit', '-m', 'Publish log entry'], + cwd=self._app.settings['source']) + + def push_git(self): + cliapp.runcmd( + ['git', 'push', 'origin', 'HEAD'], + cwd=self._app.settings['source']) + class NewPersonCommand(Command): -- cgit v1.2.1