Module: check_mk
Branch: master
Commit: c08ca2556eb18f355558100055744127339de8e7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c08ca2556eb18f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Dec 19 14:13:59 2016 +0100
werk now uses git index instead of auto commit if that is not empty
Change-Id: I5d6be05408b4b32017edbae7672471f6e232bbe4
---
werk | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/werk b/werk
index db40952..215b289 100755
--- a/werk
+++ b/werk
@@ -255,18 +255,34 @@ def git_commit(werk, custom_files):
if custom_files:
files_to_commit = custom_files
default_files = [ ".werks", "ChangeLog" ]
- # Get top level
- info = subprocess.Popen(["git", "rev-parse",
"--show-toplevel"], stdout=subprocess.PIPE)
- git_top_level = info.communicate()[0].split()[0]
for entry in default_files:
- files_to_commit.append("%s/%s" % (git_top_level, entry))
+ files_to_commit.append("%s/%s" % (git_top_level(), entry))
os.chdir(g_base_dir)
os.system("git commit %s -m %s" % ("
".join(files_to_commit),
quote_shell_string(title + "\n\n" +
werk["description"])))
else:
- os.system("git commit -a -m %s" % quote_shell_string(title +
"\n\n" + werk["description"]))
+ if something_in_git_index():
+ dash_a = ''
+ os.system("cd '%s' ; git add .werks ChangeLog" %
git_top_level())
+ else:
+ dash_a = '-a'
+
+ os.system("git commit %s -m %s" % (dash_a, quote_shell_string(title +
"\n\n" + werk["description"])))
+
+def git_top_level():
+ info = subprocess.Popen(["git", "rev-parse",
"--show-toplevel"], stdout=subprocess.PIPE)
+ git_top_level = info.communicate()[0].split()[0]
+ return git_top_level
+
+
+def something_in_git_index():
+ for line in os.popen("git status --porcelain"):
+ if line[0] == 'M':
+ return True
+ return False
+
def quote_shell_string(s):
return "'" + s.replace("'",
"'\"'\"'") + "'"