[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.

Ashley E Desimone posted 1 patch 3 years, 10 months ago
Failed in applying to current master (apply log)
edkrepo/common/common_repo_functions.py | 39 ++++++++++++++++---------
1 file changed, 26 insertions(+), 13 deletions(-)
[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.
Posted by Ashley E Desimone 3 years, 10 months ago
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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61542): https://edk2.groups.io/g/devel/message/61542
Mute This Topic: https://groups.io/mt/74995052/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.
Posted by Nate DeSimone 3 years, 10 months ago
Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: Desimone, Ashley E <ashley.e.desimone@intel.com> 
Sent: Friday, June 19, 2020 6:03 PM
To: devel@edk2.groups.io
Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Pandya, Puja <puja.pandya@intel.com>; Bjorge, Erik C <erik.c.bjorge@intel.com>; Agyeman, Prince <prince.agyeman@intel.com>; Oram, Isaac W <isaac.w.oram@intel.com>
Subject: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.

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


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#61689): https://edk2.groups.io/g/devel/message/61689
Mute This Topic: https://groups.io/mt/74995052/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-