Bug 236229

Summary: Git hooks should accept URLs in the PR field of commit logs
Product: Base System Reporter: Eric van Gyzen <vangyzen>
Component: miscAssignee: Li-Wen Hsu <lwhsu>
Status: In Progress ---    
Severity: Affects Many People CC: emaste, grahamperrin, lwhsu, vangyzen
Priority: --- Flags: grahamperrin: maintainer-feedback? (vangyzen)
Version: CURRENT   
Hardware: Any   
OS: Any   
See Also: https://reviews.freebsd.org/D19426
https://reviews.freebsd.org/D19459
https://reviews.freebsd.org/D19460
https://reviews.freebsd.org/D37863
Attachments:
Description Flags
URL redirect CGI script
none
extract_pr_numbers.py
none
test_extract_pr_numbers.py
none
extract_pr_numbers.py v2
none
test_extract_pr_numbers.py v2 none

Description Eric van Gyzen freebsd_committer freebsd_triage 2019-03-04 21:03:20 UTC
Presently, the Subversion post-commit hook only accepts numbers (and GNATS categories) in the PR field of commit logs.  Since practically everything is a URL these days, and therefore everything else knows how to _handle_ a URL, the hook should accept URLs in the PR field.

Modify hook scripts:

https://reviews.freebsd.org/D19426

Update Subversion's commit log template in src and ports:

https://reviews.freebsd.org/D19459
https://reviews.freebsd.org/D19460
Comment 1 Eric van Gyzen freebsd_committer freebsd_triage 2019-03-04 21:05:38 UTC
Created attachment 202564 [details]
URL redirect CGI script

Here is a working CGI script that could someday be used in place of Bugzilla to keep commit log URLs alive long after we migrate away from Bugzilla.
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 13:02:00 UTC
With the transition to Git, should this report be closed (overcome by events)?
Comment 3 Eric van Gyzen freebsd_committer freebsd_triage 2022-12-05 15:55:06 UTC
This feature would still be useful, no matter which VCS we use.
Comment 4 Ed Maste freebsd_committer freebsd_triage 2022-12-21 02:34:26 UTC
> This feature would still be useful, no matter which VCS we use.

Yes it would.
Comment 5 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-22 19:13:26 UTC
Created attachment 238975 [details]
extract_pr_numbers.py
Comment 6 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-22 19:13:46 UTC
Created attachment 238976 [details]
test_extract_pr_numbers.py
Comment 7 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-22 19:20:49 UTC
I've attached the updated script to extract PR numbers and its test. This has been deployed in the gitrepo-dev.freebsd.org and looks fine to me.

The only thing I would suggest is let's favor https://bugs.FreeBSD.org/###### over https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=###### , the previous one is what we kept before moving to Bugzilla (GNATS).  The comment is updated to note this one but we do support both formats in the comment message to trigger the mechanism to post comments to related tickets.
Comment 8 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-23 18:19:39 UTC
And the patch to git hook (for src repo for now, will update doc/ports then): https://reviews.freebsd.org/D37863
Comment 9 Eric van Gyzen freebsd_committer freebsd_triage 2022-12-29 01:23:46 UTC
Thank you for finishing this work, Li-Wen!  I completely forgot about it.  Let me know how I can help, if you would like.
Comment 10 Eric van Gyzen freebsd_committer freebsd_triage 2022-12-29 01:30:40 UTC
I reviewed the attached version of extract_pr_numbers.py.  lstrip() doesn't work that way.  It strips any of the given characters, so:

'https://'.lstrip(':/hpst') == ''

It happens to work in this case, but not the way we intend.
Comment 11 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-29 04:22:40 UTC
Created attachment 239104 [details]
extract_pr_numbers.py v2
Comment 12 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-29 04:23:03 UTC
Created attachment 239105 [details]
test_extract_pr_numbers.py v2
Comment 13 Li-Wen Hsu freebsd_committer freebsd_triage 2022-12-29 04:23:55 UTC
(In reply to Eric van Gyzen from comment #10)
Indeed, totally forgot about this, thanks for pointing it out. The correct way is using removeprefix().

I've updated the script and its test.
Comment 14 Graham Perrin freebsd_committer freebsd_triage 2022-12-29 13:13:31 UTC
NB <https://reviews.freebsd.org/D37863#inline-232343>