Module: check_mk
Branch: master
Commit: 9e3a3935b517ae5a29552d2de2f6aa39f8eaadae
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9e3a3935b517ae…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Mar 21 09:15:17 2016 +0100
3295 FIX Fixed exception in WATO git integration when modifying .gitingore file
---
.werks/3295 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/watolib.py | 30 ++++++++++++++++++++++--------
3 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/.werks/3295 b/.werks/3295
new file mode 100644
index 0000000..537e4a0
--- /dev/null
+++ b/.werks/3295
@@ -0,0 +1,10 @@
+Title: Fixed exception in WATO git integration when modifying .gitingore file
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1458548090
+
+
diff --git a/ChangeLog b/ChangeLog
index 8f824bc..9a72842 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -147,6 +147,7 @@
* 3270 FIX: Fix button [Deprecated Rulesets] within deprecated manual checks
rulesets
* 3100 FIX: fixed exception when trying to create a wato folder when that folder
already exists
* 3011 FIX: WATO host diagnostic page: prevent incorrectly filled input fields...
+ * 3295 FIX: Fixed exception in WATO git integration when modifying .gitingore file
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/watolib.py b/web/htdocs/watolib.py
index 691bff9..699bbc1 100644
--- a/web/htdocs/watolib.py
+++ b/web/htdocs/watolib.py
@@ -4457,26 +4457,40 @@ def do_git_commit():
git_command(["config", "user.name", "check_mk"])
write_gitignore_files()
+ git_add_files()
+ git_command(["commit", "--untracked-files=no",
"--author", author, "-m",
+ shell_quote(_("Initialized GIT for
Check_MK"))])
- git_command(["add", ".gitignore", "*.d/wato"])
- git_command(["commit", "--untracked-files=no",
"--author", author, "-m", shell_quote(_("Initialized GIT for
Check_MK"))])
-
- # Only commit, if something is changed
- if os.popen("cd '%s' && git status --porcelain" %
defaults.default_config_dir).read().strip():
+ if git_has_pending_changes():
write_gitignore_files()
- git_command(["add", "*.d/wato"])
+
+ # Writing the gitignore files might have reverted the change. So better re-check.
+ if git_has_pending_changes():
+ git_add_files()
+
message = ", ".join(g_git_messages)
if not message:
message = _("Unknown configuration change")
+
git_command(["commit", "--author", author, "-m",
shell_quote(message)])
+def git_add_files():
+ git_command(["add", ".gitignore", "*.d/wato"])
+
+
+def git_has_pending_changes():
+ return os.popen("cd '%s' && git status --porcelain" %
+ defaults.default_config_dir).read().strip()
+
+
# Make sure that .gitignore-files are present and uptodate. Only files below the
"wato" directories
# should be under git control. The files in etc/check_mk/*.mk should not be put under
control.
-#
-# FIXME TODO: Should also be written on regular commits to make it possible to update the
files
def write_gitignore_files():
file(defaults.default_config_dir + "/.gitignore", "w").write(
+ "# This file is under control of Check_MK. Please don't modify
it.\n"
+ "# Your changes will be overwritten.\n"
+ "\n"
"*\n"
"!*.d\n"
"!.gitignore\n"