[projects/git-slug: 93/170] Commit only when there is something to commit

glen glen at pld-linux.org
Mon Sep 21 21:46:37 CEST 2015


commit f1a793570c5315880685cdb10ac1ba32aabdfc3d
Author: Kacper Kornet <draenog at pld-linux.org>
Date:   Thu Mar 15 07:58:39 2012 +0000

    Commit only when there is something to commit

 git_slug/gitrepo.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/git_slug/gitrepo.py b/git_slug/gitrepo.py
index 9bc3c65..2bb59e8 100644
--- a/git_slug/gitrepo.py
+++ b/git_slug/gitrepo.py
@@ -40,8 +40,12 @@ class GitRepo:
     def commitfile(self, path, message):
         clist = ['add', path]
         self.commandexc(clist)
-        clist = ['commit', '-m', message]
-        self.commandexc(clist)
+        clist = ['diff', '--cached', '--exit-code']
+        try:
+            self.commandexc(clist)
+        except GitRepoError:
+            clist = ['commit', '-m', message]
+            self.commandexc(clist)
 
     def configvalue(self, option):
         clist = ['config', '-z', option]
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/git-slug.git/commitdiff/4ed64f73960519a2f4fd04c42950b2c96ae795c5



More information about the pld-cvs-commit mailing list