From b5bf86af7969129c94c019d8c312790b0ce62d64 Mon Sep 17 00:00:00 2001 From: Aric Gardner Date: Thu, 5 Dec 2019 16:15:20 -0500 Subject: [PATCH] Fix for empty INFO file creation Do not require and lftools [gerrit] section. Signed-off-by: Aric Gardner Change-Id: I118b4a945d6dd03231cdd7a2cbcf8cb82d35acee --- lftools/cli/infofile.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lftools/cli/infofile.py b/lftools/cli/infofile.py index b0a719ae..fde9e316 100644 --- a/lftools/cli/infofile.py +++ b/lftools/cli/infofile.py @@ -52,14 +52,8 @@ def create_info_file(ctx, gerrit_url, gerrit_project, directory, empty, tsc_appr gerrit_url example: gerrit.umbrella.com directory example: /gerrit/ (rather than most projects /r/) """ - user = config.get_setting("gerrit", "username") - pass1 = config.get_setting("gerrit", "password") - auth = HTTPBasicAuth(user, pass1) url = ("https://{}/{}".format(gerrit_url, directory)) - rest = GerritRestAPI(url=url, auth=auth) - headers = {'Content-Type': 'application/json; charset=UTF-8'} projectid_encoded = gerrit_project.replace("/", "%2F") - access_str = 'projects/{}/access'.format(projectid_encoded) # project name with only underscores for info file anchors. # project name with only dashes for ldap groups. project_underscored = gerrit_project.replace("/", "_") @@ -71,6 +65,12 @@ def create_info_file(ctx, gerrit_url, gerrit_project, directory, empty, tsc_appr umbrella_tld = match.group(0) if not empty: + user = config.get_setting("gerrit", "username") + pass1 = config.get_setting("gerrit", "password") + auth = HTTPBasicAuth(user, pass1) + rest = GerritRestAPI(url=url, auth=auth) + access_str = 'projects/{}/access'.format(projectid_encoded) + headers = {'Content-Type': 'application/json; charset=UTF-8'} result = rest.get(access_str, headers=headers) if 'inherits_from' in result: -- 2.16.6