Skip to content

Commit

Permalink
gitcommit: better status check and report
Browse files Browse the repository at this point in the history
  • Loading branch information
dr4Ke committed Jan 21, 2013
1 parent a56ce02 commit 0936367
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions 0.11/tracgitosis/tracgitosis.py
Expand Up @@ -375,28 +375,36 @@ def gitcommit(repodir, file, tracinstancename='', action='add'):
stderr = '' stderr = ''
message = '' message = ''
status = 0 status = 0
# commiting # add/remove file
cmd = ['git', action, file] cmd = ['git', action, file]
proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir) proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir)
stdout, stderr = proc.communicate() stdout, stderr = proc.communicate()
status = proc.returncode 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) proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir)
stdout, stderr = proc.communicate() stdout, stderr = proc.communicate()
status = proc.returncode status = proc.returncode
if status == 1: # commit
# check if something was commited if len(stdout) > 0:
pattern = 'nothing to commit' cmd = ['git', 'commit', '-m', 'commited by trac instance: ' + tracinstancename ]
if stdout.find(pattern) >= 0: proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir)
status = 0 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: if status == 0:
# push to gitosis # push to gitosis
cmd = ['git', 'push'] cmd = ['git', 'push']
proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir) proc = Popen(cmd, shell=False, stdin=None, stdout=PIPE, stderr=PIPE, cwd=repodir)
stdout, stderr = proc.communicate() stdout, stderr = proc.communicate()
status = proc.returncode status = proc.returncode
if status == 0: if status == 0:
message = stdout message += stdout
else: else:
message = stderr message += stdout
message += stderr
return status, message return status, message

0 comments on commit 0936367

Please sign in to comment.