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>,
	Bret Barkelew <Bret.Barkelew@microsoft.com>,
	Prince Agyeman <prince.agyeman@intel.com>
Subject: [edk2-staging/EdkRepo] [PATCH 4/4] EdkRepo: Remove support for deprecated Manifest-Repo content in edkrepo.cfg
Date: Sun, 10 May 2020 17:50:26 -0700	[thread overview]
Message-ID: <20200511005026.23532-5-ashley.e.desimone@intel.com> (raw)
In-Reply-To: <20200511005026.23532-1-ashley.e.desimone@intel.com>

Remove the remaining uses of manifest_repo_abs_local_path()
and update to use manifest_repo_abs_path where appropriate.

Remove the config prop definitions for the Manifest-Repo
section of the edkrepo.cfg file.

Remove the Manifest-Repo entry from the edkrepo.cfg file.

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: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Prince Agyeman <prince.agyeman@intel.com>
---
 edkrepo/commands/clone_command.py       |  3 ++-
 edkrepo/commands/sync_command.py        |  8 +++---
 edkrepo/common/common_repo_functions.py | 45 ++++++++++++++++++++-------------
 edkrepo/config/config_factory.py        | 12 ++-------
 edkrepo_installer/Vendor/edkrepo.cfg    |  5 ----
 5 files changed, 36 insertions(+), 37 deletions(-)

diff --git a/edkrepo/commands/clone_command.py b/edkrepo/commands/clone_command.py
index b7f3158..179aaf7 100644
--- a/edkrepo/commands/clone_command.py
+++ b/edkrepo/commands/clone_command.py
@@ -66,7 +66,6 @@ class CloneCommand(EdkrepoCommand):
 
     def run_command(self, args, config):
         pull_all_manifest_repos(config['cfg_file'], config['user_cfg_file'], False)
-        update_editor_config(config)
 
         name_or_manifest = args.ProjectNameOrManifestFile
         workspace_dir = args.Workspace
@@ -92,8 +91,10 @@ class CloneCommand(EdkrepoCommand):
         # If this manifest is in a defined manifest repository validate the manifest within the manifest repo
         if manifest_repo in cfg:
             verify_single_manifest(config['cfg_file'], manifest_repo, global_manifest_path)
+            update_editor_config(config, config['cfg_file'].manifest_repo_abs_path(manifest_repo))
         elif manifest_repo in user_cfg:
             verify_single_manifest(config['user_cfg_file'], manifest_repo, global_manifest_path)
+            update_editor_config(config, config['user_cfg_file'].manifest_repo_abs_path(manifest_repo))
 
         # Copy project manifest to local manifest dir and rename it Manifest.xml.
         local_manifest_dir = os.path.join(workspace_dir, "repo")
diff --git a/edkrepo/commands/sync_command.py b/edkrepo/commands/sync_command.py
index d1db4f1..da99397 100644
--- a/edkrepo/commands/sync_command.py
+++ b/edkrepo/commands/sync_command.py
@@ -79,8 +79,6 @@ class SyncCommand(EdkrepoCommand):
         return metadata
 
     def run_command(self, args, config):
-        update_editor_config(config)
-
         workspace_path = get_workspace_path()
         initial_manifest = get_workspace_manifest()
         current_combo = initial_manifest.general_config.current_combo
@@ -97,6 +95,8 @@ class SyncCommand(EdkrepoCommand):
             global_manifest_directory = config['user_cfg_file'].manifest_repo_abs_path(source_global_manifest_repo)
             verify_single_manifest(config['user_cfg_file'], source_global_manifest_repo, get_workspace_manifest_file(), args.verbose)
 
+        update_editor_config(config, global_manifest_directory)
+
         if not args.update_local_manifest:
             self.__check_for_new_manifest(args, config, initial_manifest, workspace_path, global_manifest_directory)
         check_dirty_repos(initial_manifest, workspace_path)
@@ -145,7 +145,7 @@ class SyncCommand(EdkrepoCommand):
         for repo_to_sync in repo_sources_to_sync:
             local_repo_path = os.path.join(workspace_path, repo_to_sync.root)
             # Update any hooks
-            update_hooks(hooks_add, hooks_update, hooks_uninstall, local_repo_path, repo_to_sync, config)
+            update_hooks(hooks_add, hooks_update, hooks_uninstall, local_repo_path, repo_to_sync, config, global_manifest_directory)
             repo = Repo(local_repo_path)
             #Fetch notes
             repo.remotes.origin.fetch("refs/notes/*:refs/notes/*")
@@ -200,7 +200,7 @@ class SyncCommand(EdkrepoCommand):
                     # Perform submodule updates and url redirection
                     maintain_submodules(repo_to_sync, repo)
             # Update commit message templates
-            update_repo_commit_template(workspace_path, repo, repo_to_sync, config)
+            update_repo_commit_template(workspace_path, repo, repo_to_sync, config, source_global_manifest_repo)
 
         if sync_error:
             print(SYNC_ERROR)
diff --git a/edkrepo/common/common_repo_functions.py b/edkrepo/common/common_repo_functions.py
index 5ec834b..61133f1 100644
--- a/edkrepo/common/common_repo_functions.py
+++ b/edkrepo/common/common_repo_functions.py
@@ -59,8 +59,8 @@ from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException
 from edkrepo_manifest_parser.edk_manifest import CiIndexXml, ManifestXml
 from edkrepo.common.edkrepo_exception import EdkrepoNotFoundException, EdkrepoGitException, EdkrepoWarningException
 from edkrepo.common.edkrepo_exception import EdkrepoFoundMultipleException, EdkrepoHookNotFoundException
-from edkrepo.common.edkrepo_exception import EdkrepoGitConfigSetupException, EdkrepoManifestInvalidException
-from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import pull_single_manifest_repo
+from edkrepo.common.edkrepo_exception import EdkrepoGitConfigSetupException, EdkrepoManifestInvalidException, EdkrepoManifestNotFoundException
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import find_source_manifest_repo, list_available_manifest_repos
 from edkrepo.common.workspace_maintenance.workspace_maintenance import case_insensitive_single_match
 from edkrepo.common.ui_functions import init_color_console
 from edkrepo_manifest_parser import edk_manifest
@@ -112,11 +112,27 @@ def clone_repos(args, workspace_dir, repos_to_clone, project_client_side_hooks,
             if repo_to_clone.enable_submodule:
                 maintain_submodules(repo_to_clone, repo, args.verbose)
 
-        # Install git hooks
-        install_hooks(project_client_side_hooks, local_repo_path, repo_to_clone, config)
+        try:
+            if 'source_manifest_repo' in vars(args).keys():
+                src_manifest_repo = find_source_manifest_repo(manifest, config['cfg_file'], config['user_cfg_file'], args.source_manifest_repo)
+            else:
+                src_manifest_repo = find_source_manifest_repo(manifest, config['cfg_file'], config['user_cfg_file'], None)
+        except EdkrepoManifestNotFoundException:
+            src_manifest_repo = None
+        if src_manifest_repo:
+            cfg, user_cfg, conflicts = list_available_manifest_repos(config['cfg_file'], config['user_cfg_file'])
+            if src_manifest_repo in cfg:
+                global_manifest_directory = config['cfg_file'].manifest_repo_abs_path(src_manifest_repo)
+            elif src_manifest_repo in user_cfg:
+                global_manifest_directory = config['user_cfg_file'].manifest_repo_abs_path(src_manifest_repo)
+            else:
+                global_manifest_directory = None
+        if global_manifest_directory:
+            # Install git hooks if there is a manifest repo associated with the manifest being cloned
+            install_hooks(project_client_side_hooks, local_repo_path, repo_to_clone, config, global_manifest_directory)
 
-        # Add the commit template if it exists.
-        update_repo_commit_template(workspace_dir, repo, repo_to_clone, config)
+            # Add the commit template if it exists.
+            update_repo_commit_template(workspace_dir, repo, repo_to_clone, config, global_manifest_directory)
 
         # Check to see if mirror is in sync with primary repo
         if not in_sync_with_primary(repo, repo_to_clone, args.verbose):
@@ -194,7 +210,7 @@ def maintain_submodules(repo_sources, repo, verbose = False):
     except:
         raise EdkrepoGitException(SUBMODULE_FAILURE.format(repo_sources.remote_name))
 
-def install_hooks(hooks, local_repo_path, repo_for_install, config):
+def install_hooks(hooks, local_repo_path, repo_for_install, config, global_manifest_directory):
     # Determine the which hooks are for the repo in question and which are from a URL based source or are in a global
     # manifest repo relative path
     hooks_url = []
@@ -222,7 +238,6 @@ def install_hooks(hooks, local_repo_path, repo_for_install, config):
 
     # Copy any global manifest repository relative path source based hooks
     for hook in hooks_path:
-        global_manifest_directory = config['cfg_file'].manifest_repo_abs_local_path
         man_dir_rel_hook_path = os.path.join(global_manifest_directory, hook.source)
         if not os.path.exists(man_dir_rel_hook_path):
             raise EdkrepoHookNotFoundException(HOOK_NOT_FOUND_ERROR.format(hook.source, repo_for_install.root))
@@ -258,11 +273,11 @@ def uninstall_hooks(hooks, local_repo_path, repo_for_uninstall):
                     hook_file = os.path.join(destination, (os.path.basename(str(hook.source))))
             os.remove(hook_file)
 
-def update_hooks (hooks_add, hooks_update, hooks_uninstall, local_repo_path, repo, config):
+def update_hooks (hooks_add, hooks_update, hooks_uninstall, local_repo_path, repo, config, global_manifest_directory):
     if hooks_add:
-        install_hooks(hooks_add, local_repo_path, repo, config)
+        install_hooks(hooks_add, local_repo_path, repo, config, global_manifest_directory)
     if hooks_update:
-        install_hooks(hooks_update, local_repo_path, repo, config)
+        install_hooks(hooks_update, local_repo_path, repo, config, global_manifest_directory)
     if hooks_uninstall:
         uninstall_hooks(hooks_uninstall, local_repo_path, repo)
 
@@ -562,15 +577,11 @@ def get_latest_sha(repo, branch, remote_or_url='origin'):
         latest_sha = None
     return latest_sha
 
-def update_repo_commit_template(workspace_dir, repo, repo_info, config):
+def update_repo_commit_template(workspace_dir, repo, repo_info, config, global_manifest_directory):
     # Open the local manifest and get any templates
     manifest = edk_manifest.ManifestXml(os.path.join(workspace_dir, 'repo', 'Manifest.xml'))
     templates = manifest.commit_templates
 
-    # Need to know where the global manifest directory is located at this point
-    global_manifest_directory = os.path.join(get_edkrepo_global_data_directory(),
-                                             config['cfg_file'].manifest_repo_local_path)
-
     # Apply the template based on current manifest
     with repo.config_writer() as cw:
         if cw.has_option(section='commit', option='template'):
@@ -590,7 +601,7 @@ def update_repo_commit_template(workspace_dir, repo, repo_info, config):
             if cw.has_option(section='commit', option='template'):
                 cw.remove_option(section='commit', option='template')
 
-def update_editor_config(config):
+def update_editor_config(config, global_manifest_directory):
     return
 
 def has_primary_repo_remote(repo, verbose=False):
diff --git a/edkrepo/config/config_factory.py b/edkrepo/config/config_factory.py
index 6d56ee6..c0b9f68 100644
--- a/edkrepo/config/config_factory.py
+++ b/edkrepo/config/config_factory.py
@@ -119,7 +119,7 @@ class BaseConfig():
         """Returns a list of available manifest repos"""
         if self.cfg.has_section('manifest-repos'):
             return self.cfg.options('manifest-repos')
-    
+
     def manifest_repo_props(self, manifest_repo):
         """
         Returns a list of cfg_prop objects that pertain to a given manifest
@@ -128,7 +128,7 @@ class BaseConfig():
         return [x for x in self.prop_list if manifest_repo in x.name]
 
     def get_manifest_repo_url(self, manifest_repo):
-        """ 
+        """
         Returns the URL value for a given manifest repo based on config
         file contents.
         """
@@ -172,9 +172,6 @@ class GlobalConfig(BaseConfig):
     def __init__(self):
         self.filename = os.path.join(get_edkrepo_global_data_directory(), "edkrepo.cfg")
         self.prop_list = [
-                CfgProp('manifest-repo', 'URL', 'manifest_repo_url', None, True),
-                CfgProp('manifest-repo', 'Branch', 'manifest_repo_branch', None, True),
-                CfgProp('manifest-repo', 'LocalPath', 'manifest_repo_local_path', None, True),
                 CfgProp('sparsecheckout', 'always_include', 'sparsecheckout_always_include', None, True),
                 CfgProp('sparsecheckout', 'always_exclude', 'sparsecheckout_always_exclude', None, True),
                 CfgProp('f2f-cherry-pick', 'ignored_folder_substrings', 'f2f_cp_ignored_folder_substrings'),
@@ -199,11 +196,6 @@ class GlobalConfig(BaseConfig):
             pkg_list.append(pkg.strip())
         return pkg_list
 
-    @property
-    def manifest_repo_abs_local_path(self):
-        """Provides an absolute path to the manifest repo based on configuration file values."""
-        return os.path.join(self.global_data_dir, self.manifest_repo_local_path)
-
     @property
     def sparsecheckout_data(self):
         always_include = self.sparsecheckout_always_include.split('|')
diff --git a/edkrepo_installer/Vendor/edkrepo.cfg b/edkrepo_installer/Vendor/edkrepo.cfg
index 38d7b35..738b832 100644
--- a/edkrepo_installer/Vendor/edkrepo.cfg
+++ b/edkrepo_installer/Vendor/edkrepo.cfg
@@ -6,11 +6,6 @@ URL = https://github.com/tianocore/edk2-staging.git
 Branch = EdkRepo-Manifest
 LocalPath = edk2-staging-manifest-master
 
-[manifest-repo]
-URL = https://github.com/tianocore/edk2-staging.git
-Branch = EdkRepo-Manifest
-LocalPath = manifest-master
-
 [git-ver]
 minimum = 2.13.0
 recommended = 2.16.2
-- 
2.16.2.windows.1


  parent reply	other threads:[~2020-05-11  0:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11  0:50 [edk2-staging/EdkRepo] [PATCH 0/4] EdkRepo: Finalize multiple manifest repository support Ashley E Desimone
2020-05-11  0:50 ` [edk2-stagin/EdkRepo] [PATCH 1/4] EdkRepo: Update sync to support multiple manifest repositories Ashley E Desimone
2020-05-11  0:50 ` [edk2-staing/EdkRepo] [PATCH 2/4] EdkRepo: Remove unused functions from common_repo_functions.py Ashley E Desimone
2020-05-11  0:50 ` [edk2-staging/EdkRepo] [PATCH 3/4] EdkRepo: Add support for multiple manifest repostories to command completions Ashley E Desimone
2020-05-11  0:50 ` Ashley E Desimone [this message]
2020-05-11  6:10 ` [edk2-devel] [edk2-staging/EdkRepo] [PATCH 0/4] EdkRepo: Finalize multiple manifest repository support Nate DeSimone
2020-05-11  6:33 ` 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=20200511005026.23532-5-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