From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web12.4349.1588782983262796128 for ; Wed, 06 May 2020 09:36:23 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Sld5iniY; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588782982; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cKCI5lBIxiBTzxv3Y5BMFysOvwZKXT2YcjbHzpgNynk=; b=Sld5iniYTkjImq1hwfUEdbuo5fHFeVuntCvLrrzmlU4MxBF1V3uPGBTnezmRyaLouW4r2B laKIgMwuMNpLdBvxB2liOVZsWwcRjb9PiniqChdwS3UwYkumO5dUr4giGSYWYaXTQ7YA13 H99bgA7/d/z7MjVE7ZE8H95Pa2k9+Ao= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-jGoF6Z2ePNWSHA08Z7wc_w-1; Wed, 06 May 2020 12:36:17 -0400 X-MC-Unique: jGoF6Z2ePNWSHA08Z7wc_w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 472AF1005510; Wed, 6 May 2020 16:36:16 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-112-227.ams2.redhat.com [10.36.112.227]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEFEF7055E; Wed, 6 May 2020 16:36:14 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools: add repo name option to SetupGit.py To: Bob Feng , Liming Gao Cc: devel@edk2.groups.io, leif@nuviainc.com, rebecca@bsdio.com References: <20200501200044.16648-1-rebecca@bsdio.com> <20200506103148.GK21486@vanye> From: "Laszlo Ersek" Message-ID: Date: Wed, 6 May 2020 18:36:13 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200506103148.GK21486@vanye> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 05/06/20 12:31, Leif Lindholm wrote: > On Tue, May 05, 2020 at 17:40:35 +0200, Laszlo Ersek wrote: >> CC Leif >> >> On 05/01/20 22:00, Rebecca Cran wrote: >>> 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 >>> Cc: Bob Feng >>> Cc: Liming Gao > > I did consider this scenario when writing the code, but couldn't > decide on a method for overriding, and wasn't 100% it wasn't just a > theoretical issue. This solution looks sensible. > Reviewed-by: Leif Lindholm Thanks! Bob, Liming, can one of you please ACK and also merge this patch? Thanks, Laszlo > > As a sidenote - now this exists, it could make sense to also add > options for overriding 'list' and 'prefix'. > > / > Leif > >>> --- >>> 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) >>> >> >> >> >> > > >