| |
@@ -409,18 +409,22 @@
|
| |
action="store",
|
| |
nargs="?",
|
| |
help="Package commit")
|
| |
- parser.add_argument("goipath", help="Import path", nargs="?")
|
| |
+ 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()
|
| |
|
| |
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):
|
| |
@@ -435,6 +439,13 @@
|
| |
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)
|
| |
|
| |
As an example, if you try to run on
pagure.io/golist
, it will work and pick the latest tag 0.9.0. This will checkout the tag aftergo get
, so everything works. But if you run it again, thengo get
will see the existing copy, get confused by theinternal
stuff, and bomb out. The--clean
/-C
option allows cleaning out the existing copy, so you can run go2rpm as many times on a previously-cached repo as you want. The--clean-all
can be used to clean the whole cache, if necessary.