[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Only process the checkout command if a valid combo is used

Ashley E Desimone posted 1 patch 3 years, 11 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
edkrepo/commands/checkout_command.py       | 18 ++++++++++++------
edkrepo/commands/humble/checkout_humble.py | 17 +++++++++++++++++
2 files changed, 29 insertions(+), 6 deletions(-)
create mode 100644 edkrepo/commands/humble/checkout_humble.py
[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Only process the checkout command if a valid combo is used
Posted by Ashley E Desimone 3 years, 11 months ago
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/checkout_command.py       | 18 ++++++++++++------
 edkrepo/commands/humble/checkout_humble.py | 17 +++++++++++++++++
 2 files changed, 29 insertions(+), 6 deletions(-)
 create mode 100644 edkrepo/commands/humble/checkout_humble.py

diff --git a/edkrepo/commands/checkout_command.py b/edkrepo/commands/checkout_command.py
index 7d65eb8..bc8a080 100644
--- a/edkrepo/commands/checkout_command.py
+++ b/edkrepo/commands/checkout_command.py
@@ -14,8 +14,11 @@ import os
 
 # Our modules
 from edkrepo.commands.edkrepo_command import EdkrepoCommand, OverrideArgument
-import edkrepo.commands.arguments.checkout_args as arguments
-from edkrepo.common.common_repo_functions import checkout
+import edkrepo.commands.arguments.checkout_args as arguments
+import edkrepo.command.humble.checkout_humble as humble
+from edkrepo.common.common_repo_functions import checkout, combination_is_in_manifest
+from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException
+from edkrepo.config.config_factory import get_workspace_manifest
 
 
 class CheckoutCommand(EdkrepoCommand):
@@ -25,17 +28,20 @@ class CheckoutCommand(EdkrepoCommand):
     def get_metadata(self):
         metadata = {}
         metadata['name'] = 'checkout'
-        metadata['help-text'] = arguments.COMMAND_DESCRIPTION
+        metadata['help-text'] = arguments.COMMAND_DESCRIPTION
         args = []
         metadata['arguments'] = args
         args.append({'name' : 'Combination',
                      'positional' : True,
                      'position' : 0,
                      'required': True,
-                     'description' : arguments.COMBINATION_DESCRIPTION,
-                     'help-text' : arguments.COMBINATION_HELP})
+                     'description' : arguments.COMBINATION_DESCRIPTION,
+                     'help-text' : arguments.COMBINATION_HELP})
         args.append(OverrideArgument)
         return metadata
 
     def run_command(self, args, config):
-        checkout(args.Combination, args.verbose, args.override)
+        if combination_is_in_manifest(args.Combination, get_workspace_manifest()):
+            checkout(args.Combination, args.verbose, args.override)
+        else:
+            raise EdkrepoInvalidParametersException(humble.NO_COMBO)
diff --git a/edkrepo/commands/humble/checkout_humble.py b/edkrepo/commands/humble/checkout_humble.py
new file mode 100644
index 0000000..ec0ffc1
--- /dev/null
+++ b/edkrepo/commands/humble/checkout_humble.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+#
+## @file
+# checkout_humble.py
+#
+# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+
+CHP_EXIT = 'Exiting without checkout out PIN data.'
+NOT_FOUND = 'The selected PIN file was not found.'
+MANIFEST_MISMATCH = ('The selected PIN file does not refer to the same project '
+                     'as the local manifest file. {}'.format(CHP_EXIT))
+COMMIT_NOT_FOUND = 'The commit referenced by the PIN file does not exist. {}'.format(CHP_EXIT)
+PIN_COMBO = 'Pin: {}'
+COMBO_NOT_FOUND = ('Warning: The combo listed in PIN file: {} is no longer '
+                   'listed in the project manifest file.')
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59469): https://edk2.groups.io/g/devel/message/59469
Mute This Topic: https://groups.io/mt/74193675/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Only process the checkout command if a valid combo is used
Posted by Nate DeSimone 3 years, 11 months ago
Hi Ashley,

Please update the copyright year on checkout_command.py

Also, please see additional comments inline.

Thanks,
Nate

> -----Original Message-----
> From: Desimone, Ashley E <ashley.e.desimone@intel.com>
> Sent: Wednesday, May 13, 2020 3:33 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-staging/EdkRepo] [PATCH] EdkRepo: Only process the
> checkout command if a valid combo is used
> 
> 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/checkout_command.py       | 18 ++++++++++++------
>  edkrepo/commands/humble/checkout_humble.py | 17 +++++++++++++++++
>  2 files changed, 29 insertions(+), 6 deletions(-)
>  create mode 100644 edkrepo/commands/humble/checkout_humble.py
> 
> diff --git a/edkrepo/commands/checkout_command.py b/edkrepo/commands/checkout_command.py
> index 7d65eb8..bc8a080 100644
> --- a/edkrepo/commands/checkout_command.py
> +++ b/edkrepo/commands/checkout_command.py
> @@ -14,8 +14,11 @@ import os
>  
>  # Our modules
>  from edkrepo.commands.edkrepo_command import EdkrepoCommand, OverrideArgument
> -import edkrepo.commands.arguments.checkout_args as arguments
> -from edkrepo.common.common_repo_functions import checkout
> +import edkrepo.commands.arguments.checkout_args as arguments
> +import edkrepo.command.humble.checkout_humble as humble

This is incorrect, it should be: import edkrepo.commands.humble.checkout_humble as humble

> +from edkrepo.common.common_repo_functions import checkout, combination_is_in_manifest
> +from edkrepo.common.edkrepo_exception import EdkrepoInvalidParametersException
> +from edkrepo.config.config_factory import get_workspace_manifest
>  
>  
>  class CheckoutCommand(EdkrepoCommand):
> @@ -25,17 +28,20 @@ class CheckoutCommand(EdkrepoCommand):
>      def get_metadata(self):
>          metadata = {}
>          metadata['name'] = 'checkout'
> -        metadata['help-text'] = arguments.COMMAND_DESCRIPTION
> +        metadata['help-text'] = arguments.COMMAND_DESCRIPTION
>          args = []
>          metadata['arguments'] = args
>          args.append({'name' : 'Combination',
>                       'positional' : True,
>                       'position' : 0,
>                       'required': True,
> -                     'description' : arguments.COMBINATION_DESCRIPTION,
> -                     'help-text' : arguments.COMBINATION_HELP})
> +                     'description' : arguments.COMBINATION_DESCRIPTION,
> +                     'help-text' : arguments.COMBINATION_HELP})
>          args.append(OverrideArgument)
>          return metadata
>  
>      def run_command(self, args, config):
> -        checkout(args.Combination, args.verbose, args.override)
> +        if combination_is_in_manifest(args.Combination, get_workspace_manifest()):
> +            checkout(args.Combination, args.verbose, args.override)
> +        else:
> +            raise EdkrepoInvalidParametersException(humble.NO_COMBO)

NO_COMBO is not defined in checkout_humble.py

> diff --git a/edkrepo/commands/humble/checkout_humble.py b/edkrepo/commands/humble/checkout_humble.py
> new file mode 100644
> index 0000000..ec0ffc1
> --- /dev/null
> +++ b/edkrepo/commands/humble/checkout_humble.py
> @@ -0,0 +1,17 @@
> +#!/usr/bin/env python3
> +#
> +## @file
> +# checkout_humble.py
> +#
> +# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +
> +CHP_EXIT = 'Exiting without checkout out PIN data.'
> +NOT_FOUND = 'The selected PIN file was not found.'
> +MANIFEST_MISMATCH = ('The selected PIN file does not refer to the same project '
> +                     'as the local manifest file. {}'.format(CHP_EXIT))
> +COMMIT_NOT_FOUND = 'The commit referenced by the PIN file does not exist. {}'.format(CHP_EXIT)
> +PIN_COMBO = 'Pin: {}'
> +COMBO_NOT_FOUND = ('Warning: The combo listed in PIN file: {} is no longer '
> +                   'listed in the project manifest file.')
> -- 
> 2.16.2.windows.1

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#59617): https://edk2.groups.io/g/devel/message/59617
Mute This Topic: https://groups.io/mt/74193675/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-