public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Rebecca Cran" <rebecca@bsdio.com>
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@bsdio.com>, Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <liming.gao@intel.com>
Subject: [PATCH 1/1] BaseTools: add repo name option to SetupGit.py
Date: Fri,  1 May 2020 14:00:44 -0600	[thread overview]
Message-ID: <20200501200044.16648-1-rebecca@bsdio.com> (raw)

Allow users who didn't clone one of the TianoCore repos from a
canonical URL to specify the name of the repo (edk2, edk2-platforms
or edk2-non-osi) when running SetupGit.py to allow them to configure
their repo properly.

The new option is:

  -n repo, --name repo  set the repo name to configure for, if not
                        detected automatically

Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
Tested with:
  pylama : no new issues detected
Option tested:
  -n : correctly said a parameter was needed
  -n edk2 : configured the repo for edk2
  -n edk2-foo : errored out with a list of repo names
  -n edk2-platforms : updated the configuration for edk2-platforms

Note the error block in __main__ if the upstream isn't found is
redundant, since it already errors out and exits in get_upstream.

 BaseTools/Scripts/SetupGit.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py
index e320ba2f887e..4416111ac0a5 100644
--- a/BaseTools/Scripts/SetupGit.py
+++ b/BaseTools/Scripts/SetupGit.py
@@ -106,10 +106,11 @@ def fuzzy_match_repo_url(one, other):
     return False
 
 
-def get_upstream(url):
+def get_upstream(url, name):
     """Extracts the dict for the current repo origin."""
     for upstream in UPSTREAMS:
-        if fuzzy_match_repo_url(upstream['repo'], url):
+        if (fuzzy_match_repo_url(upstream['repo'], url) or
+                upstream['name'] == name):
             return upstream
     print("Unknown upstream '%s' - aborting!" % url)
     sys.exit(3)
@@ -143,6 +144,11 @@ if __name__ == '__main__':
                         help='overwrite existing settings conflicting with program defaults',
                         action='store_true',
                         required=False)
+    PARSER.add_argument('-n', '--name', type=str, metavar='repo',
+                        choices=['edk2', 'edk2-platforms', 'edk2-non-osi'],
+                        help='set the repo name to configure for, if not '
+                             'detected automatically',
+                        required=False)
     PARSER.add_argument('-v', '--verbose',
                         help='enable more detailed output',
                         action='store_true',
@@ -156,7 +162,7 @@ if __name__ == '__main__':
 
     URL = REPO.remotes.origin.url
 
-    UPSTREAM = get_upstream(URL)
+    UPSTREAM = get_upstream(URL, ARGS.name)
     if not UPSTREAM:
         print("Upstream '%s' unknown, aborting!" % URL)
         sys.exit(7)
-- 
2.25.1



             reply	other threads:[~2020-05-01 20:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-01 20:00 Rebecca Cran [this message]
2020-05-05 15:40 ` [edk2-devel] [PATCH 1/1] BaseTools: add repo name option to SetupGit.py Laszlo Ersek
2020-05-06 10:31   ` Leif Lindholm
2020-05-06 16:36     ` Laszlo Ersek
2020-05-07  2:11       ` Bob Feng
2020-05-07  7:42 ` Philippe Mathieu-Daudé

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=20200501200044.16648-1-rebecca@bsdio.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