Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Closes tags with custom Bugzilla resolution #190

Closed
wants to merge 4 commits into from

Conversation

antecrescent
Copy link
Contributor

@antecrescent antecrescent commented Jun 25, 2024

This PR is part of a larger effort[1] to automate resolving bugs on Gentoo's Bugzilla with the correct resolutions.
The command line syntax would be:

  • <bug>:<resolution> for a given bgo bug with an explicit resolution
  • <bug>: or <bug> for any bug without a resolution (implicitly FIXED for a bgo bug)

Apart from FIXED, I chose to support:

  • OBSOLETE e.g. for when older versions of a package get dropped which implicitly fixes a bug
  • PKGREMOVED to encourage its adoption for the removal of packages

If you think any resolutions are missing here, please tell me!

I wasn't sure how to handle malformed URL-like input with multiple colons like https://foo:bar:obsolete. Currently, it gets converted into a Closes: https://foo:bar (obsolete) tag, similar to how -T/--tag does it.


[1]: Patch for infra's githooks: https://bugs.gentoo.org/934825

Copy link
Member

@arthurzam arthurzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much! This is great :)

@@ -40,3 +40,8 @@ def _GET_CONST(attr, default_value):
USER_CONF_FILE = os.path.join(getattr(_module, "USER_CONFIG_PATH"), "pkgdev.conf")
SYSTEM_CONF_FILE = "/etc/pkgdev/pkgdev.conf"
BUNDLED_CONF_FILE = os.path.join(DATA_PATH, "pkgdev.conf")

BZ_FIXED = "fixed"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please define it using python's enum.Enum, you can get all the know values from it

raise ValueError("URL-like value without resolution")
res = res.lower() if res else const.BZ_FIXED
if not (bug and res in const.BZ_RESOLUTIONS):
raise argparse.ArgumentError(self, f"invalid commit tag: {values}")
Copy link
Member

@arthurzam arthurzam Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
raise argparse.ArgumentError(self, f"invalid commit tag: {values}")
raise argparse.ArgumentError(self, f"invalid commit tag {res!r}, should be one of: {values}")

return

url = self.parse_url(bug)
is_bgo = url.split("//", 1)[1].startswith("bugs.gentoo.org")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
is_bgo = url.split("//", 1)[1].startswith("bugs.gentoo.org")
is_bgo = "bugs.gentoo.org" in url

We can be simpler, even if not 100% quality check

@antecrescent
Copy link
Contributor Author

Thanks for the feedback! I've been busy all week and I'll be implementing it on Sunday. Sorry for the delay!

Support resolutions FIXED, OBSOLETE and PKGREMOVED, provided that the
bug belongs to b.g.o.  The default and fallback resolution is FIXED.

Together with server-side changes to
https://gitweb.gentoo.org/infra/githooks.git/, this patch allows Gentoo
contributors to generate commit tags that cause bugs to be closed
automatically with the indicated resolution.

Currently, only the string after the last colon in the argument is
significant for the resolution.  Therefore, one could theoretically
craft invalid tags such as
'Closes: https://bugs.gentoo.org/123:foo (obsolete)'

Signed-off-by: Lucio Sauer <[email protected]>
_comp_ltrim_colon_completions was introduced with
>=bash-completion-2.12

Signed-off-by: Lucio Sauer <[email protected]>
Copy link
Member

@arthurzam arthurzam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you very much, looks and works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants