#9744 distgit-branch-unused: When another name is used, keep checking
Merged 10 days ago by mohanboddu. Opened 2 months ago by churchyard.
churchyard/releng another_name_keep_looking  into  master

@@ -81,7 +81,13 @@ 

  def list_builds(package, opts):

      session, koji = koji_session(opts)

  

-     pkg = session.getPackageID(package, strict=True)

+     try:

+         pkg = session.getPackageID(package, strict=True)

+     except koji.GenericError as e:

+         if 'Invalid package name' in str(e):

+             return {}

+         else:

+             raise

      builds = session.listBuilds(packageID=pkg, state=koji.BUILD_STATES['COMPLETE'])

  

      with session.multicall(strict=True) as msession:
@@ -128,8 +134,19 @@ 

      try:

          spec = (commit.tree / f'{package}.spec').data

      except KeyError:

-         print(f"Commit {commit.hex} doesn't have '{package}.spec', assuming package is unbuildable.")

-         return None

+         print(f"Commit {commit.hex} doesn't have '{package}.spec', looking for other specs.")

+         specs = set()

+         for candidate in commit.tree:

+             if candidate.name.endswith(".spec"):

+                 specs.add(candidate)

+                 print(f"Found '{candidate.name}'.")

+         if not specs:

+             print(f"Commit {commit.hex} doesn't have '*.spec', assuming package is unbuildable.")

+             return None

+         if len(specs) > 1:

+             msg = f"Commit {commit.hex} has multiple '*.spec' files, aborting."

+             raise NotImplementedError(msg)

+         spec = specs.pop().data

  

      # We don't try to decode the whole spec file here, to reduce the chances of trouble.

      # Just any interesting lines.
@@ -187,7 +204,7 @@ 

          return 0

  

      print('Branch has commits not found anywhere else. Looking for builds.')

-     builds = list_builds(opts.package, opts)

+     builds = {opts.package: list_builds(opts.package, opts)}

  

      for n, commit in enumerate(repo.walk(branch.target, pygit2.GIT_SORT_TOPOLOGICAL)):

          subj = commit.message.splitlines()[0][:60]
@@ -208,16 +225,17 @@ 

              real_name = name_in_spec_file(commit, opts.package)

          except UnicodeDecodeError:

              return 1

-         if real_name is not None and real_name != opts.package:

-             print(f"Sorry, {commit.hex} has Name: {real_name}, refusing to continue.")

-             return 1

- 

-         built = builds.get(commit.hex, None)

-         if built:

-             print(f"Sorry, {commit.hex} built as {built['nvr']}.")

-             koji_link = f"https://koji.fedoraproject.org/koji/taskinfo?taskID={built['task_id']}"

-             print(f"See {koji_link}.")

-             return 1

+         if real_name is not None and real_name not in builds:

+             print(f"{commit.hex} has Name: {real_name}. Looking for builds.")

+             builds[real_name] = list_builds(real_name, opts)

+ 

+         for name in builds:

+             built = builds[name].get(commit.hex, None)

+             if built:

+                 print(f"Sorry, {commit.hex} built as {built['nvr']}.")

+                 koji_link = f"https://koji.fedoraproject.org/koji/taskinfo?taskID={built['task_id']}"

+                 print(f"See {koji_link}.")

+                 return 1

  

      print('No builds found, seems OK to delete.')

      return 0

no initial comment

1 new commit added

  • distgit-branch-unused: Also consider other spec files
2 months ago

2 new commits added

  • distgit-branch-unused: Also consider other spec files
  • distgit-branch-unused: When another name is used, keep checking
2 months ago

rebased onto 0adc909

a month ago

rebased onto 61f3cb6

15 days ago

Can this be merged in please?

rebased onto a8de6da

10 days ago

Pull-Request has been merged by mohanboddu

10 days ago
Metadata