public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Agyeman, Prince" <prince.agyeman@intel.com>
To: "Desimone, Ashley E" <ashley.e.desimone@intel.com>,
	"devel@edk2.groups.io" <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>
Subject: Re: [edk2-staging/EdkRepo] [PATCH V2 2/3] EdkRepo: Add edkrepo/common/workspace_maitenance/manifest_repos_maitenance
Date: Wed, 22 Apr 2020 22:35:41 +0000	[thread overview]
Message-ID: <DM6PR11MB34650A5E869F49357B5929159AD20@DM6PR11MB3465.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200422213523.44888-3-ashley.e.desimone@intel.com>

Hi Ashley,

Comment below

Prince

-----Original Message-----
From: Desimone, Ashley E <ashley.e.desimone@intel.com> 
Sent: Wednesday, April 22, 2020 2:35 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 V2 2/3] EdkRepo: Add edkrepo/common/workspace_maitenance/manifest_repos_maitenance

Add a directory to edkrepo/common to store workspace maitenance functionatlity.
Add edkrepo/common/workspace_matenance/humble directory to store related strings and included manifest_repos_maitenance_humble.py
Add edkrepo/common/workspace_maitenance/manifest_repos_maitenance.py
to support the maitenance of multiple manifest repositories.
Added pull_single_manifest_repo() to manifest_repos_maitenance.py Updated setup.py to include the new directories.

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>
---
 .../humble/manifest_repos_maitenance_humble.py     | 23 +++++++++
 .../manifest_repos_maitenance.py                   | 59 ++++++++++++++++++++++
 setup.py                                           |  5 +-
 3 files changed, 85 insertions(+), 2 deletions(-)  create mode 100644 edkrepo/common/workspace_maitenance/humble/manifest_repos_maitenance_humble.py
 create mode 100644 edkrepo/common/workspace_maitenance/manifest_repos_maitenance.py

diff --git a/edkrepo/common/workspace_maitenance/humble/manifest_repos_maitenance_humble.py b/edkrepo/common/workspace_maitenance/humble/manifest_repos_maitenance_humble.py
new file mode 100644
index 0000000..ee7b4bb
--- /dev/null
+++ b/edkrepo/common/workspace_maitenance/humble/manifest_repos_maitenan
+++ ce_humble.py
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+#
+## @file
+# manifest_repos_mgmt_humble.py
+#
+# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR> 
+# SPDX-License-Identifier: BSD-2-Clause-Patent #
+
+''' Contains user facing strings for manifest_repos_mgmt.py '''
+
+from colorama import Fore
+from colorama import Style
+
+CLONE_SINGLE_MAN_REPO = 'Cloning global manifest repository to: {} from: {}'
+SYNC_SINGLE_MAN_REPO = 'Syncing the global manifest repository: {}'
+SINGLE_MAN_REPO_DIRTY = ('Uncommited changes present in the global manifest '
+                         'repository: {} Resolve these changes and attempt your'
+                         ' operation again.') 
+SINGLE_MAN_REPO_NOT_CFG_BRANCH = ('The current active branch, {}, is not the '
+                                  'specified branch for global manifst 
+repository: {}') SINGLE_MAN_REPO_CHECKOUT_CFG_BRANCH = 'Checking out the specified branch: {} prior to syncing'
+SINGLE_MAN_REPO_MOVED = '{}{}WARNING:{}{} The global manifest 
+repository has moved. Backing up previous global manifest repository 
+to: {{}}{}\n'.format(Style.BRIGHT, Fore.RED, Style.RESET_ALL, Fore.RED, 
+Style.RESET_ALL)
\ No newline at end of file
diff --git a/edkrepo/common/workspace_maitenance/manifest_repos_maitenance.py b/edkrepo/common/workspace_maitenance/manifest_repos_maitenance.py
new file mode 100644
index 0000000..8944492
--- /dev/null
+++ b/edkrepo/common/workspace_maitenance/manifest_repos_maitenance.py
@@ -0,0 +1,59 @@
+#!/usr/bin/env python3
+#
+## @file
+# manifest_repos_mgmt.py
+#
+# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.<BR> 
+# SPDX-License-Identifier: BSD-2-Clause-Patent #
+
+import os
+import traceback
+import shutil
+
+import git
+from git import Repo
+
+import edkrepo.config.config_factory as cfg from 
+edkrepo.common.edkrepo_exception import 
+EdkrepoUncommitedChangesException from edkrepo.common.progress_handler 
+import GitProgressHandler import 
+edkrepo.common.workspace_maitenance.humble.manifest_repos_maitenance_hu
+mble as humble from 
+edkrepo.common.workspace_maitenance.workspace_maitenance import 
+generate_name_for_obsolete_backup
+
+
+def pull_single_manifest_repo(url, branch, local_path, reset_hard=False):
+    '''
+    Clones or syncs a single global manifest repository as defined in either
+    the edkrepo.cfg or the edkrepo_user.cfg
+    '''
+    # If a relative path is used join to the edkrepo global data directory path
+    if not os.path.isabs(local_path):
+        local_path = os.path.join(cfg.get_edkrepo_global_data_directory(), local_path)
+    # Clone the repository if it does not exist locally
+    if not os.path.exists(local_path):
+        print(humble.CLONE_SINGLE_MAN_REPO.format(local_path, url))
+        repo = Repo.clone_from(url, local_path, progress=GitProgressHandler(), branch=branch)
+    # Sync the repository if it exists locally
+    else:
+        repo = Repo(local_path)
+        if url in repo.remotes['origin'].urls:
+            if repo.is_dirty(untracked_files=True) and not reset_hard:
+                raise EdkrepoUncommitedChangesException(humble.SINGLE_MAN_REPO_DIRTY.format(local_path))
+            elif repo.is_dirty(untracked_files=True) and reset_hard:
+                repo.git.reset('--hard')
+            print(humble.SYNC_SINGLE_MAN_REPO.format(local_path))
+            if repo.active_branch.name != branch:
+                print(humble.SINGLE_MAN_REPO_NOT_CFG_BRANCH.format(repo.active_branch.name, local_path))
+                print(humble.SINGLE_MAN_REPO_CHECKOUT_CFG_BRANCH.format(branch))
+                repo.git.checkout(branch)
+            repo.remotes.origin.pull()
+        # If the URL specified for this manifest repo has moved back up the existing
+        # local copy and clone the new repository
+        else:
+            new_path = generate_name_for_obsolete_backup(local_path)
+            new_path = os.path.join(os.path.dirname(local_path), new_path)

Typo SINGLE_MANE_REPO_MOVED , should be  SINGLE_MAN_REPO_MOVED
+            print(humble.SINGLE_MANE_REPO_MOVED.format(new_path))
+            shutil.move(local_path, new_path)
+            print (humble.CLONE_SIGNLE_MAN_REPO.format(local_path, url))
+            repo = Repo.clone_from(url, local_path, 
+progress=GitProgressHandler(), branch=branch)
+
diff --git a/setup.py b/setup.py
index 06a382b..f8bb0fc 100755
--- a/setup.py
+++ b/setup.py
@@ -12,8 +12,9 @@ setup(name='edkrepo',
       version='2.0.0',
       description='The edkrepo tools',
       packages=['edkrepo', 'edkrepo.commands', 'edkrepo.commands.arguments', 'edkrepo.commands.humble',
-                'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.config', 'edkrepo.config.humble',
-                'edkrepo_manifest_parser', 'project_utils'],
+                'edkrepo.git_automation', 'edkrepo.common', 'edkrepo.common.workspace_maitenance',
+                'edkrepo.common.workspace_maitenance.humble', 'edkrepo.config', 'edkrepo.config.humble',
+                'edkrepo_manifest_parser', 'project_utils'],
       package_data={
          },
       include_package_data=True,
--
2.16.2.windows.1


  reply	other threads:[~2020-04-22 22:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22 21:35 [edk2-devel] [edk2-staging/EdkRepo][PATCH V2 0/3] EdkRepo: Add initial manifest repository support Ashley E Desimone
2020-04-22 21:35 ` [edk2-staging/EdkRepo] [PATCH V2 1/3] EdkRepo: Initial commit of workspace_maitenance.py Ashley E Desimone
2020-04-22 21:35 ` [edk2-staging/EdkRepo] [PATCH V2 2/3] EdkRepo: Add edkrepo/common/workspace_maitenance/manifest_repos_maitenance Ashley E Desimone
2020-04-22 22:35   ` Agyeman, Prince [this message]
2020-04-22 21:35 ` [edk2-staging/EdkRepo] [PATCH V2 3/3] EdkRepo: Update pull_latest_manifest_repo to use pull_single_manifest_repo Ashley E 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=DM6PR11MB34650A5E869F49357B5929159AD20@DM6PR11MB3465.namprd11.prod.outlook.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