Reviewed-by: Nate DeSimone <nathaniel.l.desim...@intel.com> -----Original Message----- From: Desimone, Ashley E <ashley.e.desim...@intel.com> Sent: Friday, June 19, 2020 6:03 PM To: devel@edk2.groups.io Cc: Desimone, Nathaniel L <nathaniel.l.desim...@intel.com>; Pandya, Puja <puja.pan...@intel.com>; Bjorge, Erik C <erik.c.bjo...@intel.com>; Agyeman, Prince <prince.agye...@intel.com>; Oram, Isaac W <isaac.w.o...@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.desim...@intel.com> Cc: Nate DeSimone <nathaniel.l.desim...@intel.com> Cc: Puja Pandya <puja.pan...@intel.com> Cc: Erik Bjorge <erik.c.bjo...@intel.com> Cc: Prince Agyeman <prince.agye...@intel.com> Cc: Isaac Oram <isaac.w.o...@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/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-