public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ashley E Desimone" <ashley.e.desimone@intel.com>
To: devel@edk2.groups.io
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>,
	Puja Pandya <puja.pandya@intel.com>,
	Erik Bjorge <erik.c.bjorge@intel.com>,
	Prince Agyeman <prince.agyeman@intel.com>,
	Isaac Oram <isaac.w.oram@intel.com>
Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.
Date: Fri, 19 Jun 2020 18:02:47 -0700	[thread overview]
Message-ID: <20200620010247.2577-1-ashley.e.desimone@intel.com> (raw)

Signed-off-by: Ashley E Desimone <ashley.e.desimone@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Puja Pandya <puja.pandya@intel.com>
Cc: Erik Bjorge <erik.c.bjorge@intel.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
Cc: Isaac Oram <isaac.w.oram@intel.com>
---
 edkrepo/common/common_repo_functions.py | 39 ++++++++++++++++---------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/edkrepo/common/common_repo_functions.py b/edkrepo/common/common_repo_functions.py
index 59c198f..313a1ca 100644
--- a/edkrepo/common/common_repo_functions.py
+++ b/edkrepo/common/common_repo_functions.py
@@ -558,21 +558,34 @@ def update_repo_commit_template(workspace_dir, repo, repo_info, config, global_m
     manifest = edk_manifest.ManifestXml(os.path.join(workspace_dir, 'repo', 'Manifest.xml'))
     templates = manifest.commit_templates
 
+    #Check for the presence of a gloablly defined commit template
+    global_template_in_use = False
+    global_gitconfig_path = os.path.normpath(os.path.expanduser("~/.gitconfig"))
+    with git.GitConfigParser(global_gitconfig_path, read_only=False) as gitglobalconfig:
+        if gitglobalconfig.has_option(section='commit', option='template'):
+            global_template = gitglobalconfig.get_value(section='commit', option='template')
+            global_template_in_use = True
+            print(COMMIT_TEMPLATE_CUSTOM_VALUE.format(repo_info.remote_name))
+
     # Apply the template based on current manifest
     with repo.config_writer() as cw:
-        if cw.has_option(section='commit', option='template'):
-            current_template = cw.get_value(section='commit', option='template').replace('"', '')
-            if not current_template.startswith(os.path.normpath(global_manifest_directory).replace('\\', '/')):
-                print(COMMIT_TEMPLATE_CUSTOM_VALUE.format(repo_info.remote_name))
-                return
-
-        if repo_info.remote_name in templates:
-            template_path = os.path.normpath(os.path.join(global_manifest_directory, templates[repo_info.remote_name]))
-            if not os.path.isfile(template_path):
-                print(COMMIT_TEMPLATE_NOT_FOUND.format(template_path))
-                return
-            template_path = template_path.replace('\\', '/')    # Convert to git approved path
-            cw.set_value(section='commit', option='template', value='"{}"'.format(template_path))
+        if not global_template_in_use:
+            if cw.has_option(section='commit', option='template'):
+                current_template = cw.get_value(section='commit', option='template').replace('"', '')
+                if not current_template.startswith(os.path.normpath(global_manifest_directory).replace('\\', '/')):
+                    print(COMMIT_TEMPLATE_CUSTOM_VALUE.format(repo_info.remote_name))
+                    return
+
+            if repo_info.remote_name in templates:
+                template_path = os.path.normpath(os.path.join(global_manifest_directory, templates[repo_info.remote_name]))
+                if not os.path.isfile(template_path):
+                    print(COMMIT_TEMPLATE_NOT_FOUND.format(template_path))
+                    return
+                template_path = template_path.replace('\\', '/')    # Convert to git approved path
+                cw.set_value(section='commit', option='template', value='"{}"'.format(template_path))
+            else:
+                if cw.has_option(section='commit', option='template'):
+                    cw.remove_option(section='commit', option='template')
         else:
             if cw.has_option(section='commit', option='template'):
                 cw.remove_option(section='commit', option='template')
-- 
2.26.2.windows.1


             reply	other threads:[~2020-06-20  1:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20  1:02 Ashley E Desimone [this message]
2020-06-24 16:17 ` [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined Nate DeSimone

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200620010247.2577-1-ashley.e.desimone@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox