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

Support for logical OR in plugins, i.e. one of these must succeed #76

Open
boudekerk opened this issue Sep 14, 2023 · 4 comments · May be fixed by #77
Open

Support for logical OR in plugins, i.e. one of these must succeed #76

boudekerk opened this issue Sep 14, 2023 · 4 comments · May be fixed by #77

Comments

@boudekerk
Copy link
Contributor

boudekerk commented Sep 14, 2023

Within our company there are two Jira instances (merger/acquisition), and originally different teams used different instances, so we copied and renamed the CheckJira plugin for the second instance.

Now we're in the situation that for some projects multiple keys, from different instances should be allowed. We can probably solve that by using the CheckLog plugin, but the log messages become very unclear to users.

githooks.checkjira1.matchkey=\b[A-Z][A-Z]+\d?-\d+\b
githooks.checkjira1.require=false
githooks.checkjira2.matchkey=\b[A-Z][A-Z]+\d?-\d+\b
githooks.checkjira2.require=false
githooks.checklog.title-match=(\b[A-Z][A-Z]+\d?-\d+\b)|<CUSTOM COMMIT MESSAGE>

It would be nice if somehow multiple Jira instances could be supported with an option of requiring a valid jira key from one of the two.

@boudekerk
Copy link
Contributor Author

boudekerk commented Sep 14, 2023

One thought I had was perhaps a separate property which could have a condition specifying which plugins should (or shouldn't?) match.

Something like this for the above case:

githooks.checkjira1.matchkey=\b[A-Z][A-Z]+\d?-\d+\b
githooks.checkjira1.require=true
githooks.checkjira2.matchkey=\b[A-Z][A-Z]+\d?-\d+\b
githooks.checkjira2.require=true
githooks.checklog.title-match=<CUSTOM COMMIT MESSAGE>

githooks.eval=(checkjira1 || checkjira2 || checklog)

Then that would also solve the #58 issue I think, as the logging would be a lot clearer.

Maybe a bit simpler might be adding something in the plugin string, like ! for disabling. | could be prefixed.
i.e.

githooks.plugins=CheckLog CheckJira1|CheckJira2

In this case CheckLog would always have to match, and either CheckJira1 or CheckJira2

@boudekerk
Copy link
Contributor Author

Just realised that the initial config won't even work for us. It will check the key against both instances, so one will always fail.

@gnustavo Do you see a solution?

@boudekerk boudekerk changed the title Support for multiple Jira instances Support for OR in plugins Sep 18, 2023
@boudekerk boudekerk changed the title Support for OR in plugins Support for logical OR in plugins, i.e. one of these must succeed Sep 18, 2023
@boudekerk boudekerk linked a pull request Sep 19, 2023 that will close this issue
@boudekerk
Copy link
Contributor Author

I've implemented the second/simpler proposal in #77.

It would be appreciated if you could consider this.

@boudekerk
Copy link
Contributor Author

@gnustavo Any further thoughts on this?

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 a pull request may close this issue.

1 participant