From 0936367420a17b97b02b136976d225b662dff460 Mon Sep 17 00:00:00 2001 From: dr4Ke Date: Mon, 21 Jan 2013 08:48:33 +0100 Subject: [PATCH] gitcommit: better status check and report --- 0.11/tracgitosis/tracgitosis.py | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/0.11/tracgitosis/tracgitosis.py b/0.11/tracgitosis/tracgitosis.py index d88dfd7..1b34bce 100644 --- a/0.11/tracgitosis/tracgitosis.py +++ b/0.11/tracgitosis/tracgitosis.py @@ -375,20 +375,27 @@ def gitcommit(repodir, file, tracinstancename='', action='add'): stderr = '' message = '' status = 0 - # commiting + # add/remove file cmd = ['git', action, file] proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir) stdout, stderr = proc.communicate() status = proc.returncode - cmd = ['git', 'commit', '-m', 'commited by trac instance: ' + tracinstancename ] + # check status + cmd = ['git', 'status', '--short'] proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir) stdout, stderr = proc.communicate() status = proc.returncode - if status == 1: - # check if something was commited - pattern = 'nothing to commit' - if stdout.find(pattern) >= 0: - status = 0 + # commit + if len(stdout) > 0: + cmd = ['git', 'commit', '-m', 'commited by trac instance: ' + tracinstancename ] + proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir) + stdout, stderr = proc.communicate() + status = proc.returncode + if status == 1: + # check if something was commited + pattern = 'nothing to commit' + if stdout.find(pattern) >= 0: + status = 0 if status == 0: # push to gitosis cmd = ['git', 'push'] @@ -396,7 +403,8 @@ def gitcommit(repodir, file, tracinstancename='', action='add'): stdout, stderr = proc.communicate() status = proc.returncode if status == 0: - message = stdout + message += stdout else: - message = stderr + message += stdout + message += stderr return status, message