Bug 236229 - Git hooks should accept URLs in the PR field of commit logs
Summary: Git hooks should accept URLs in the PR field of commit logs
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: Li-Wen Hsu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-04 21:03 UTC by Eric van Gyzen
Modified: 2022-12-29 13:13 UTC (History)
4 users (show)

See Also:
grahamperrin: maintainer-feedback? (vangyzen)


Attachments
URL redirect CGI script (208 bytes, text/plain)
2019-03-04 21:05 UTC, Eric van Gyzen
no flags Details
extract_pr_numbers.py (2.42 KB, text/plain)
2022-12-22 19:13 UTC, Li-Wen Hsu
no flags Details
test_extract_pr_numbers.py (3.31 KB, text/plain)
2022-12-22 19:13 UTC, Li-Wen Hsu
no flags Details
extract_pr_numbers.py v2 (2.44 KB, text/plain)
2022-12-29 04:22 UTC, Li-Wen Hsu
no flags Details
test_extract_pr_numbers.py v2 (3.37 KB, text/plain)
2022-12-29 04:23 UTC, Li-Wen Hsu
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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>