public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update Create-Pin to be support multiple manifest repositories
@ 2020-05-10  3:21 Ashley E Desimone
  2020-05-10  3:44 ` [edk2-devel] " Nate DeSimone
  2020-05-10  3:51 ` Nate DeSimone
  0 siblings, 2 replies; 3+ messages in thread
From: Ashley E Desimone @ 2020-05-10  3:21 UTC (permalink / raw)
  To: devel
  Cc: Nate DeSimone, Puja Pandya, Erik Bjorge, Bret Barkelew,
	Prince Agyeman

Update the create pin command to select and interact with only
the workspaces source manifest repository.

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/create_pin_command.py | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/edkrepo/commands/create_pin_command.py b/edkrepo/commands/create_pin_command.py
index f8618e5..24180ba 100644
--- a/edkrepo/commands/create_pin_command.py
+++ b/edkrepo/commands/create_pin_command.py
@@ -12,14 +12,16 @@ from collections import namedtuple
 
 from git import Repo
 
-from edkrepo.commands.edkrepo_command import EdkrepoCommand
+from edkrepo.commands.edkrepo_command import EdkrepoCommand, SourceManifestRepoArgument
 import edkrepo.commands.arguments.create_pin_args as arguments
-from edkrepo.common.common_repo_functions import pull_latest_manifest_repo
 from edkrepo.common.edkrepo_exception import EdkrepoManifestInvalidException, EdkrepoInvalidParametersException
 from edkrepo.common.edkrepo_exception import EdkrepoWorkspaceCorruptException
 from edkrepo.common.humble import WRITING_PIN_FILE, GENERATING_PIN_DATA, GENERATING_REPO_DATA, BRANCH, COMMIT
 from edkrepo.common.humble import COMMIT_MESSAGE, PIN_PATH_NOT_PRESENT, PIN_FILE_ALREADY_EXISTS, PATH_AND_FILEPATH_USED
 from edkrepo.common.humble import MISSING_REPO
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import find_source_manifest_repo
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import list_available_manifest_repos
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import pull_workspace_manifest_repo
 from edkrepo.config.config_factory import get_workspace_manifest, get_workspace_path
 from edkrepo_manifest_parser.edk_manifest import ManifestXml
 
@@ -49,6 +51,7 @@ class CreatePinCommand(EdkrepoCommand):
                      'positional': False,
                      'required': False,
                      'help-text': arguments.PUSH_HELP})
+        args.append(SourceManifestRepoArgument)
         return metadata
 
     def run_command(self, args, config):
@@ -56,14 +59,21 @@ class CreatePinCommand(EdkrepoCommand):
         if args.push and os.path.dirname(args.PinFileName):
             raise EdkrepoInvalidParametersException(PATH_AND_FILEPATH_USED)
 
-        pull_latest_manifest_repo(args, config)
         workspace_path = get_workspace_path()
         manifest = get_workspace_manifest()
 
+        if args.push:
+            src_manifest_repo = find_source_manifest_repo(manifest, config['cfg_file'], config['user_cfg_file'], args.source_manifest_repo)
+            pull_workspace_manifest_repo(manifest, config['cfg_file'], config['user_cfg_file'], args.source_manifest_repo, False)
+            cfg, user_cfg, conflicts = list_available_manifest_repos(config['cfg_file'], config['user_cfg_file'])
+            if src_manifest_repo in cfg:
+                manifest_repo_path = config['cfg_file'].manifest_repo_abs_path(src_manifest_repo)
+            elif src_manifest_repo in user_cfg:
+                manifest_repo_path = config['user_cfg_file'].manifest_repo_abs_path(src_manifest_repo)
         # If the push flag is enabled use general_config.pin_path to determine global manifest relative location to save
         # pin file to.
         if args.push and manifest.general_config.pin_path is not None:
-            pin_dir = os.path.join(config['cfg_file'].manifest_repo_abs_local_path, os.path.normpath(manifest.general_config.pin_path))
+            pin_dir = os.path.join(manifest_repo_path, os.path.normpath(manifest.general_config.pin_path))
             pin_file_name = os.path.join(pin_dir, args.PinFileName)
         elif args.push and manifest.general_config.pin_path is None:
             raise EdkrepoManifestInvalidException(PIN_PATH_NOT_PRESENT)
@@ -104,7 +114,7 @@ class CreatePinCommand(EdkrepoCommand):
 
         # commit and push the pin file
         if args.push:
-            manifest_repo = Repo(config['cfg_file'].manifest_repo_abs_local_path)
+            manifest_repo = Repo(manifest_repo_path)
             # Create a local branch with the same name as the pin file arg and check it out before attempting the push
             # to master
             master_branch = manifest_repo.active_branch
@@ -124,4 +134,4 @@ class CreatePinCommand(EdkrepoCommand):
                 manifest_repo.git.push('origin', 'HEAD:master')
             finally:
                 manifest_repo.heads[master_branch.name].checkout()
-                manifest_repo.delete_head(local_branch, '-D')
\ No newline at end of file
+                manifest_repo.delete_head(local_branch, '-D')
-- 
2.16.2.windows.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update Create-Pin to be support multiple manifest repositories
  2020-05-10  3:21 [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update Create-Pin to be support multiple manifest repositories Ashley E Desimone
@ 2020-05-10  3:44 ` Nate DeSimone
  2020-05-10  3:51 ` Nate DeSimone
  1 sibling, 0 replies; 3+ messages in thread
From: Nate DeSimone @ 2020-05-10  3:44 UTC (permalink / raw)
  To: devel@edk2.groups.io, Desimone, Ashley E
  Cc: Pandya, Puja, Bjorge, Erik C, Bret Barkelew, Agyeman, Prince

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ashley E
> Desimone
> Sent: Saturday, May 9, 2020 8:22 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>; Bret
> Barkelew <Bret.Barkelew@microsoft.com>; Agyeman, Prince
> <prince.agyeman@intel.com>
> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update
> Create-Pin to be support multiple manifest repositories
> 
> Update the create pin command to select and interact with only the
> workspaces source manifest repository.
> 
> 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/create_pin_command.py | 22 ++++++++++++++++----
> --
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/edkrepo/commands/create_pin_command.py
> b/edkrepo/commands/create_pin_command.py
> index f8618e5..24180ba 100644
> --- a/edkrepo/commands/create_pin_command.py
> +++ b/edkrepo/commands/create_pin_command.py
> @@ -12,14 +12,16 @@ from collections import namedtuple
> 
>  from git import Repo
> 
> -from edkrepo.commands.edkrepo_command import EdkrepoCommand
> +from edkrepo.commands.edkrepo_command import EdkrepoCommand,
> +SourceManifestRepoArgument
>  import edkrepo.commands.arguments.create_pin_args as arguments -from
> edkrepo.common.common_repo_functions import
> pull_latest_manifest_repo  from edkrepo.common.edkrepo_exception
> import EdkrepoManifestInvalidException,
> EdkrepoInvalidParametersException  from
> edkrepo.common.edkrepo_exception import
> EdkrepoWorkspaceCorruptException  from edkrepo.common.humble import
> WRITING_PIN_FILE, GENERATING_PIN_DATA, GENERATING_REPO_DATA,
> BRANCH, COMMIT  from edkrepo.common.humble import
> COMMIT_MESSAGE, PIN_PATH_NOT_PRESENT, PIN_FILE_ALREADY_EXISTS,
> PATH_AND_FILEPATH_USED  from edkrepo.common.humble import
> MISSING_REPO
> +from
> edkrepo.common.workspace_maintenance.manifest_repos_maintenance
> +import find_source_manifest_repo from
> +edkrepo.common.workspace_maintenance.manifest_repos_maintenance
> import
> +list_available_manifest_repos from
> +edkrepo.common.workspace_maintenance.manifest_repos_maintenance
> import
> +pull_workspace_manifest_repo
>  from edkrepo.config.config_factory import get_workspace_manifest,
> get_workspace_path  from edkrepo_manifest_parser.edk_manifest import
> ManifestXml
> 
> @@ -49,6 +51,7 @@ class CreatePinCommand(EdkrepoCommand):
>                       'positional': False,
>                       'required': False,
>                       'help-text': arguments.PUSH_HELP})
> +        args.append(SourceManifestRepoArgument)
>          return metadata
> 
>      def run_command(self, args, config):
> @@ -56,14 +59,21 @@ class CreatePinCommand(EdkrepoCommand):
>          if args.push and os.path.dirname(args.PinFileName):
>              raise
> EdkrepoInvalidParametersException(PATH_AND_FILEPATH_USED)
> 
> -        pull_latest_manifest_repo(args, config)
>          workspace_path = get_workspace_path()
>          manifest = get_workspace_manifest()
> 
> +        if args.push:
> +            src_manifest_repo = find_source_manifest_repo(manifest,
> config['cfg_file'], config['user_cfg_file'], args.source_manifest_repo)
> +            pull_workspace_manifest_repo(manifest, config['cfg_file'],
> config['user_cfg_file'], args.source_manifest_repo, False)
> +            cfg, user_cfg, conflicts =
> list_available_manifest_repos(config['cfg_file'], config['user_cfg_file'])
> +            if src_manifest_repo in cfg:
> +                manifest_repo_path =
> config['cfg_file'].manifest_repo_abs_path(src_manifest_repo)
> +            elif src_manifest_repo in user_cfg:
> +                manifest_repo_path =
> + config['user_cfg_file'].manifest_repo_abs_path(src_manifest_repo)
>          # If the push flag is enabled use general_config.pin_path to determine
> global manifest relative location to save
>          # pin file to.
>          if args.push and manifest.general_config.pin_path is not None:
> -            pin_dir =
> os.path.join(config['cfg_file'].manifest_repo_abs_local_path,
> os.path.normpath(manifest.general_config.pin_path))
> +            pin_dir = os.path.join(manifest_repo_path,
> + os.path.normpath(manifest.general_config.pin_path))
>              pin_file_name = os.path.join(pin_dir, args.PinFileName)
>          elif args.push and manifest.general_config.pin_path is None:
>              raise EdkrepoManifestInvalidException(PIN_PATH_NOT_PRESENT)
> @@ -104,7 +114,7 @@ class CreatePinCommand(EdkrepoCommand):
> 
>          # commit and push the pin file
>          if args.push:
> -            manifest_repo =
> Repo(config['cfg_file'].manifest_repo_abs_local_path)
> +            manifest_repo = Repo(manifest_repo_path)
>              # Create a local branch with the same name as the pin file arg and
> check it out before attempting the push
>              # to master
>              master_branch = manifest_repo.active_branch @@ -124,4 +134,4 @@
> class CreatePinCommand(EdkrepoCommand):
>                  manifest_repo.git.push('origin', 'HEAD:master')
>              finally:
>                  manifest_repo.heads[master_branch.name].checkout()
> -                manifest_repo.delete_head(local_branch, '-D')
> \ No newline at end of file
> +                manifest_repo.delete_head(local_branch, '-D')
> --
> 2.16.2.windows.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update Create-Pin to be support multiple manifest repositories
  2020-05-10  3:21 [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update Create-Pin to be support multiple manifest repositories Ashley E Desimone
  2020-05-10  3:44 ` [edk2-devel] " Nate DeSimone
@ 2020-05-10  3:51 ` Nate DeSimone
  1 sibling, 0 replies; 3+ messages in thread
From: Nate DeSimone @ 2020-05-10  3:51 UTC (permalink / raw)
  To: devel@edk2.groups.io, Desimone, Ashley E
  Cc: Pandya, Puja, Bjorge, Erik C, Bret Barkelew, Agyeman, Prince

Pushed: 706536b63ba06bfb6a2b3a5800ff6cc53bd11e84

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ashley E
> Desimone
> Sent: Saturday, May 9, 2020 8:22 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>; Bret
> Barkelew <Bret.Barkelew@microsoft.com>; Agyeman, Prince
> <prince.agyeman@intel.com>
> Subject: [edk2-devel] [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update
> Create-Pin to be support multiple manifest repositories
> 
> Update the create pin command to select and interact with only the
> workspaces source manifest repository.
> 
> 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/create_pin_command.py | 22 ++++++++++++++++----
> --
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/edkrepo/commands/create_pin_command.py
> b/edkrepo/commands/create_pin_command.py
> index f8618e5..24180ba 100644
> --- a/edkrepo/commands/create_pin_command.py
> +++ b/edkrepo/commands/create_pin_command.py
> @@ -12,14 +12,16 @@ from collections import namedtuple
> 
>  from git import Repo
> 
> -from edkrepo.commands.edkrepo_command import EdkrepoCommand
> +from edkrepo.commands.edkrepo_command import EdkrepoCommand,
> +SourceManifestRepoArgument
>  import edkrepo.commands.arguments.create_pin_args as arguments -from
> edkrepo.common.common_repo_functions import
> pull_latest_manifest_repo  from edkrepo.common.edkrepo_exception
> import EdkrepoManifestInvalidException,
> EdkrepoInvalidParametersException  from
> edkrepo.common.edkrepo_exception import
> EdkrepoWorkspaceCorruptException  from edkrepo.common.humble import
> WRITING_PIN_FILE, GENERATING_PIN_DATA, GENERATING_REPO_DATA,
> BRANCH, COMMIT  from edkrepo.common.humble import
> COMMIT_MESSAGE, PIN_PATH_NOT_PRESENT, PIN_FILE_ALREADY_EXISTS,
> PATH_AND_FILEPATH_USED  from edkrepo.common.humble import
> MISSING_REPO
> +from
> edkrepo.common.workspace_maintenance.manifest_repos_maintenance
> +import find_source_manifest_repo from
> +edkrepo.common.workspace_maintenance.manifest_repos_maintenance
> import
> +list_available_manifest_repos from
> +edkrepo.common.workspace_maintenance.manifest_repos_maintenance
> import
> +pull_workspace_manifest_repo
>  from edkrepo.config.config_factory import get_workspace_manifest,
> get_workspace_path  from edkrepo_manifest_parser.edk_manifest import
> ManifestXml
> 
> @@ -49,6 +51,7 @@ class CreatePinCommand(EdkrepoCommand):
>                       'positional': False,
>                       'required': False,
>                       'help-text': arguments.PUSH_HELP})
> +        args.append(SourceManifestRepoArgument)
>          return metadata
> 
>      def run_command(self, args, config):
> @@ -56,14 +59,21 @@ class CreatePinCommand(EdkrepoCommand):
>          if args.push and os.path.dirname(args.PinFileName):
>              raise
> EdkrepoInvalidParametersException(PATH_AND_FILEPATH_USED)
> 
> -        pull_latest_manifest_repo(args, config)
>          workspace_path = get_workspace_path()
>          manifest = get_workspace_manifest()
> 
> +        if args.push:
> +            src_manifest_repo = find_source_manifest_repo(manifest,
> config['cfg_file'], config['user_cfg_file'], args.source_manifest_repo)
> +            pull_workspace_manifest_repo(manifest, config['cfg_file'],
> config['user_cfg_file'], args.source_manifest_repo, False)
> +            cfg, user_cfg, conflicts =
> list_available_manifest_repos(config['cfg_file'], config['user_cfg_file'])
> +            if src_manifest_repo in cfg:
> +                manifest_repo_path =
> config['cfg_file'].manifest_repo_abs_path(src_manifest_repo)
> +            elif src_manifest_repo in user_cfg:
> +                manifest_repo_path =
> + config['user_cfg_file'].manifest_repo_abs_path(src_manifest_repo)
>          # If the push flag is enabled use general_config.pin_path to determine
> global manifest relative location to save
>          # pin file to.
>          if args.push and manifest.general_config.pin_path is not None:
> -            pin_dir =
> os.path.join(config['cfg_file'].manifest_repo_abs_local_path,
> os.path.normpath(manifest.general_config.pin_path))
> +            pin_dir = os.path.join(manifest_repo_path,
> + os.path.normpath(manifest.general_config.pin_path))
>              pin_file_name = os.path.join(pin_dir, args.PinFileName)
>          elif args.push and manifest.general_config.pin_path is None:
>              raise EdkrepoManifestInvalidException(PIN_PATH_NOT_PRESENT)
> @@ -104,7 +114,7 @@ class CreatePinCommand(EdkrepoCommand):
> 
>          # commit and push the pin file
>          if args.push:
> -            manifest_repo =
> Repo(config['cfg_file'].manifest_repo_abs_local_path)
> +            manifest_repo = Repo(manifest_repo_path)
>              # Create a local branch with the same name as the pin file arg and
> check it out before attempting the push
>              # to master
>              master_branch = manifest_repo.active_branch @@ -124,4 +134,4 @@
> class CreatePinCommand(EdkrepoCommand):
>                  manifest_repo.git.push('origin', 'HEAD:master')
>              finally:
>                  manifest_repo.heads[master_branch.name].checkout()
> -                manifest_repo.delete_head(local_branch, '-D')
> \ No newline at end of file
> +                manifest_repo.delete_head(local_branch, '-D')
> --
> 2.16.2.windows.1
> 
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-10  3:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-10  3:21 [edk2-staging/EdkRepo] [PATCH V3] EdkRepo: Update Create-Pin to be support multiple manifest repositories Ashley E Desimone
2020-05-10  3:44 ` [edk2-devel] " Nate DeSimone
2020-05-10  3:51 ` Nate DeSimone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox