From fd903e9d743765ddca9a85fd07f4c7dea539f3e4 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: May 07 2019 05:00:36 +0000 Subject: [PATCH 1/2] Make goipath actually required. --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index fe0754d..1063771 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -409,18 +409,15 @@ def main(): action="store", nargs="?", help="Package commit") - parser.add_argument("goipath", help="Import path", nargs="?") + parser.add_argument("goipath", help="Import path") args = parser.parse_args() if args.show_license_map: licensing.dump_sdpx_to_fedora_map(sys.stdout) return - if args.goipath is None: - parser.error("required import path argument missing") - else: - goipath = re.sub(r"^http(s?)://", r"", args.goipath) - goipath = goipath.strip('/') + goipath = re.sub(r"^http(s?)://", r"", args.goipath) + goipath = goipath.strip('/') if (not re.search(r"^(github.com|gitlab.com|bitbucket.org)", goipath) and args.forge is None): From 2a82d513f4300f59a72e1800ea253ac84cbeedd3 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: May 07 2019 05:00:36 +0000 Subject: [PATCH 2/2] Add a cache cleaning option. --- diff --git a/go2rpm/__main__.py b/go2rpm/__main__.py index 1063771..4e87557 100644 --- a/go2rpm/__main__.py +++ b/go2rpm/__main__.py @@ -409,6 +409,13 @@ def main(): action="store", nargs="?", help="Package commit") + parser.add_argument("-C", + "--clean", + action="store_true", + help="Clean cache for chosen Go import path") + parser.add_argument("--clean-all", + action="store_true", + help="Clean all cached Go imports") parser.add_argument("goipath", help="Import path") args = parser.parse_args() @@ -432,6 +439,13 @@ def main(): args.forge = 'https://' + args.forge forge = args.forge.strip('/') + # Clean any existing repos, if requested. + if args.clean_all: + shutil.rmtree(GIT_CACHEDIR, ignore_errors=True) + elif args.clean: + shutil.rmtree(os.path.join(GIT_CACHEDIR, *get_repo_host(goipath)), + ignore_errors=True) + # Download the repo download(goipath)