#199 rust2rpm: fix existence check logic and tweak printed warnings
Merged 2 years ago by zbyszek. Opened 2 years ago by decathorpe.
Unknown source main  into  main

file modified
+11 -3
@@ -292,7 +292,7 @@

      # E.g. https://src.fedoraproject.org/rpms/rust-tiny_http0.6/blob/rawhide/f/rust-tiny_http0.6.spec

      full_url = json['full_url']

      spec_url = requests.compat.urljoin(full_url, f'blob/rawhide/f/rust-{package}.spec')

-     req = requests.head(url, headers={"User-Agent": "rust2rpm"})

+     req = requests.head(spec_url, headers={"User-Agent": "rust2rpm"})

  

      if not req.ok:

          # The repo exists, but doesn't have the spec file. We most
@@ -514,9 +514,17 @@

      if args.target in {"fedora"} and args.existence_check and not os.path.exists(spec_file):

          # No specfile, so this is probably a new package

          package_info = get_package_info(pkg_name)

+ 

          if package_info:

-             print(f"Crate {pkg_name} is already packaged in Fedora ({package_info['full_url']}).")

-             print("Re-run with --no-existence-check if you still want to convert it.")

+             if args.suffix:

+                 print(f"Versions {args.suffix}.* of the crate '{metadata.name}' are already")

+                 print(f"packaged for Fedora: {package_info['full_url']}")

+ 

+             else:

+                 print(f"Crate '{metadata.name}' is already packaged for Fedora:")

+                 print(f"{package_info['full_url']}")

+ 

+             print("Re-run with --no-existence-check if you still want to start from scratch.")

              sys.exit(1)

  

      kwargs["auto_changelog_entry"] = args.auto_changelog_entry

  • use correct URL for the detection of the presence of .spec files

This fixes the existence check for repositories that exist but have no .spec file yet.

  • tweak warnings after successful existence check

This adapts the warning messages depending the presence of a "--suffix" argument, i.e. whether a compat package is created or not, and adapts some of the formatting to more often fit into a standard terminal width (80 characters) without adding line breaks in the middle of the URL.

Pull-Request has been merged by zbyszek

2 years ago
Metadata