[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.
Nate DeSimone
nathaniel.l.desimone at intel.com
Wed Jun 24 16:17:02 UTC 2020
Reviewed-by: Nate DeSimone <nathaniel.l.desimone at intel.com>
-----Original Message-----
From: Desimone, Ashley E <ashley.e.desimone at intel.com>
Sent: Friday, June 19, 2020 6:03 PM
To: devel at edk2.groups.io
Cc: Desimone, Nathaniel L <nathaniel.l.desimone at intel.com>; Pandya, Puja <puja.pandya at intel.com>; Bjorge, Erik C <erik.c.bjorge at intel.com>; Agyeman, Prince <prince.agyeman at intel.com>; Oram, Isaac W <isaac.w.oram at 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 at intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
Cc: Puja Pandya <puja.pandya at intel.com>
Cc: Erik Bjorge <erik.c.bjorge at intel.com>
Cc: Prince Agyeman <prince.agyeman at intel.com>
Cc: Isaac Oram <isaac.w.oram at 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/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-
More information about the edk2-devel-archive
mailing list