* [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.
@ 2020-06-20 1:02 Ashley E Desimone
2020-06-24 16:17 ` Nate DeSimone
0 siblings, 1 reply; 2+ messages in thread
From: Ashley E Desimone @ 2020-06-20 1:02 UTC (permalink / raw)
To: devel; +Cc: Nate DeSimone, Puja Pandya, Erik Bjorge, Prince Agyeman,
Isaac Oram
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined.
2020-06-20 1:02 [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined Ashley E Desimone
@ 2020-06-24 16:17 ` Nate DeSimone
0 siblings, 0 replies; 2+ messages in thread
From: Nate DeSimone @ 2020-06-24 16:17 UTC (permalink / raw)
To: Desimone, Ashley E, devel@edk2.groups.io
Cc: Pandya, Puja, Bjorge, Erik C, Agyeman, Prince, Oram, Isaac W
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-06-24 16:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-20 1:02 [edk2-staging/EdkRepo] [PATCH] EdkRepo: Do not write a local commit template when a global one is defined Ashley E Desimone
2020-06-24 16:17 ` Nate DeSimone
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox