#7 Add some cache cleaning options
Merged 9 months ago by eclipseo. Opened 9 months ago by qulogic.
GoSIG/ qulogic/go2rpm clean-cache  into  master

file modified
+17 -6

@@ -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 after go get, so everything works. But if you run it again, then go get will see the existing copy, get confused by the internal 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.

But if you run it again, then go get will see the existing copy, get confused by the internal stuff, and bomb out.

I don't quite get the reason for this? I can run go get -d -u pagure.io/golist/... multiple times with no error, yet it fails from within go2rpm?

Pull-Request has been merged by eclipseo

9 months ago
Metadata