#9744 distgit-branch-unused: When another name is used, keep checking
Merged 3 years ago by mohanboddu. Opened 3 years 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
3 years ago

2 new commits added

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

rebased onto 0adc909744bd584f915ea66fbc124df720f7d42e

3 years ago

rebased onto 61f3cb666c7fcf8cd89baf77ea53b5320eadc038

3 years ago

Can this be merged in please?

rebased onto a8de6da

3 years ago

Pull-Request has been merged by mohanboddu

3 years ago
Metadata