From 2cae617bfc660104a4c21fdbc5af451cee15e179 Mon Sep 17 00:00:00 2001 From: Matteo Gamboz Date: Fri, 14 Feb 2025 17:40:53 +0100 Subject: [PATCH 1/4] Always honor "package.git.autocommit" if provided by a config file --- bobtemplates/plone/base.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/bobtemplates/plone/base.py b/bobtemplates/plone/base.py index df3e4736..2a2072e3 100644 --- a/bobtemplates/plone/base.py +++ b/bobtemplates/plone/base.py @@ -117,28 +117,32 @@ def git_init(configurator): def git_commit(configurator, msg): if not git_support(configurator): return - non_interactive = configurator.bobconfig.get("non_interactive") working_dir = ( configurator.variables.get("package.root_folder") or configurator.target_directory ) params1 = ["git", "add", "."] params2 = ["git", "commit", "-m", '"{0}"'.format(msg)] - git_autocommit = None - run_git_commit = True - autocommit_flag = configurator.variables.get("package.git.autocommit", "False") - if hooks.to_boolean(None, None, autocommit_flag): - git_autocommit = True - if not non_interactive and not git_autocommit: - echo( - "Should we run?:\n{0}\n{1}\nin: {2}".format( - " ".join(params1), " ".join(params2), working_dir - ), - "info", - ) - run_git_commit = (input("[y]/n: ") or "y").lower() == "y" - - if not run_git_commit and not git_autocommit: + variable = "package.git.autocommit" + if variable in configurator.variables: + # The operator requested a certain behavior, + # we should oblige, irrespective of interactive/non-interactive + run_git_commit = hooks.to_boolean(None, None, configurator.variables.get(variable)) + else: + # no indication from the operator: now we ask only if in interactive mode + non_interactive = configurator.bobconfig.get("non_interactive") + if non_interactive: + run_git_commit = True + else: + echo( + "Should we run?:\n{0}\n{1}\nin: {2}".format( + " ".join(params1), " ".join(params2), working_dir + ), + "info", + ) + run_git_commit = (input("[y]/n: ") or "y").lower() == "y" + + if not run_git_commit: echo("Skip git commit!", "warning") return From a8f9332734e8f62581889d48647dc3d2743c64ee Mon Sep 17 00:00:00 2001 From: Matteo Gamboz Date: Fri, 14 Feb 2025 17:43:11 +0100 Subject: [PATCH 2/4] fix syntax error in .editorconfig --- .editorconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index d841167d..9995fe98 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,7 +9,8 @@ root = true -[*] # For All Files +[*] +# For All Files # Unix-style newlines with a newline ending every file end_of_line = lf insert_final_newline = true From 2e4d05cf782480c53298093cfcec26da7b8f9dcc Mon Sep 17 00:00:00 2001 From: Matteo Gamboz Date: Thu, 20 Feb 2025 13:56:38 +0100 Subject: [PATCH 3/4] add changelog entry --- CHANGES.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 2c94c840..8f658373 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,8 @@ Changelog 6.4.2 (unreleased) ------------------ -- Nothing changed yet. +- Honor "package.git.autocommit" variable + [gamboz] 6.4.1 (2025-01-20) From 8700bd145d3717084a191c9454d51ec692235067 Mon Sep 17 00:00:00 2001 From: Matteo Gamboz Date: Thu, 20 Feb 2025 14:02:26 +0100 Subject: [PATCH 4/4] fix code formatting --- bobtemplates/plone/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bobtemplates/plone/base.py b/bobtemplates/plone/base.py index 2a2072e3..ebe23485 100644 --- a/bobtemplates/plone/base.py +++ b/bobtemplates/plone/base.py @@ -127,7 +127,9 @@ def git_commit(configurator, msg): if variable in configurator.variables: # The operator requested a certain behavior, # we should oblige, irrespective of interactive/non-interactive - run_git_commit = hooks.to_boolean(None, None, configurator.variables.get(variable)) + run_git_commit = hooks.to_boolean( + None, None, configurator.variables.get(variable) + ) else: # no indication from the operator: now we ask only if in interactive mode non_interactive = configurator.bobconfig.get("non_interactive")