Commit graph

17 commits

Author SHA1 Message Date
Luca Pizzamiglio
302c208fc5 Component: git hooks
Add common error function in hooks
Error messages are printed in stderr

Reviewed By: tcberner, #portmgr
Differential Revision: https://reviews.freebsd.org/D38026
2023-01-12 22:09:50 +01:00
Matthias Andree
414b5c6164 .hooks/pre-commit.d: unbreak EPOCH checker
dns/dnsmasq-devel as of 2.88rc3 contained a comment about PORTEPOCH,
which I removed in the 2.88rc5. This tripped up the checker because
it assumed that if git yielded lines containing PORTEPOCH, then it
must have been PORTEPOCH= or similar lines. Untrue in my case.

It was printing
[pre-commit] dropped PORTEPOCH  in dns/dnsmasq-devel/Makefile

To solve, only pick out PORTEPOCH diffs that are actual assignments,
and if the new PORTEPOCH is empty, and the old one is also,
ignore this condition (previously we would exit 1, which is bogus).

Also, grep without -E should not have \ in front of - or +.
FreeBSD 13.1 grep is fine, but GNU grep ignores those backslashes
noisily (and I have prepended it to PATH) and emits warnings.

PR:		268024
2022-12-18 09:58:17 +01:00
Matthias Andree
df32a2be1d .hooks/pre-commit.d: Revert "unbreak EPOCH checker"
This reverts commit e0dd1e987a.
No consensus yet, and escaped after messing up my branches.
2022-12-17 00:42:36 +01:00
Matthias Andree
e0dd1e987a .hooks/pre-commit.d: unbreak EPOCH checker
dns/dnsmasq-devel as of 2.88rc3 contained a comment about PORTEPOCH,
which I removed in the 2.88rc5. This tripped up the checker because
it assumed that if git yielded lines containing PORTEPOCH, then it
must have been PORTEPOCH= or similar lines. Untrue in my case.

It was printing
[pre-commit] dropped PORTEPOCH  in dns/dnsmasq-devel/Makefile

To solve, only pick out PORTEPOCH diffs that are actual assignments,
and if the new PORTEPOCH is empty, and the old one is also,
ignore this condition (previously we would exit 1, which is bogus).

Also, grep without -E should not have \ in front of - or +.
FreeBSD 13.1 grep is fine, but GNU grep ignores those backslashes
noisily (and I have prepended it to PATH) and emits warnings.
2022-12-16 23:08:29 +01:00
Tobias C. Berner
30aaa5ae3f framework: fix grep call in check_files hook
Reported by:		dch
2022-11-16 06:18:26 +01:00
Tobias C. Berner
537c7c0004 framework: new hook to only allow 'default' files in category/port
This hooks enforces that all files in the top-directory of a port match:
  - .*\.mk
  - Makefile.*
  - distinfo.*
  - pkg-.*

An example error message would look like:

 [pre-commit] ERROR: invalid file 'Foo' in 'kate/editors'
             Consider moving non-standard files to files/ or force-ignore this hook.

Differential Revision: https://reviews.freebsd.org/D37387
2022-11-15 19:20:27 +01:00
Tobias C. Berner
5ad46769a8 framework: add git-hook to check PORTEPOCH validity
- checks dropping of PORTEPOCH:
	[pre-commit] dropped PORTEPOCH 1 in net/kf5-kdav/Makefile

- checks it being non-decreasing:
	[pre-commit] PORTEPOCH decreasing from 2 to 1 in net-p2p/frost/Makefile

Reviewed By: rene, bapt
Differential Revision: https://reviews.freebsd.org/D35733
2022-11-11 21:39:46 +01:00
Tobias C. Berner
951773c013 framework: add new hook to validate MOVED lines
A possible error message will look like:

[pre-commit] ERROR: MOVED contains errors.
                    Please apply the suggested changes:

17537: date going backwards from 2022-08-20 to 2022-08-13 from this line
17538: date going backwards from 2022-08-20 to 2022-08-13 to this line

Reviewed by:		bapt
Differential Revision:	https://reviews.freebsd.org/D35042
2022-08-23 15:08:11 +02:00
Tobias C. Berner
242b704fb5 framework: add hook to notify about lingering 'Created by' lines 2022-07-20 15:09:29 +02:00
Tobias C. Berner
27bebbf28a framework: add hook to check indentation of conditionals of Mk/ files
This adds a further pre-commit hook to enforce indentations in Mk/*

Usage:
	> vim Mk/Uses/tcl.mk
	[add/remove some whitespaces between a `.` and an `if`]
	> git add Mk/Uses/tcl.mk
	> git commit -m "Mk/Uses/tcl.mk: test hook"
	[pre-commit] tcl.mk is not properly indented -- please use /tmp/check_indentations-tcl.mk.LShfR7TD48/tcl.mk which was created using Tools/scripts/indent_make_if.pl

Reminder: to make use of the hooks provided by the ports tree use the
following from [1]

    Add the prepare-commit-msg hook to the repository.

    To make use of it, the easiest way is to run:

      git config --add core.hooksPath .hooks

[1] bbc2474ef7

Reviewed by:		portmgr (rene)
Differential Revision:	https://reviews.freebsd.org/D35041
2022-04-25 19:34:55 +02:00
Tobias C. Berner
4e21a051bb framework: create a sub-directory to support multiple pre-commit hooks 2022-04-24 12:24:28 +02:00
Tobias C. Berner
ea589ebd66 framework: add hook to detect whether new ports are hooked into the tree
This pre-commit hook looks for newly added files matching
	foo/bar/Makefile

For these files, it is checking that a SUBDIR+=bar entry is
present in foo/Makefile.

Example run output:
	> mkdir -p graphics/test_port
	> touch graphics/test_port/Makefile
	> git add graphics/test_port/Makefile
	> git commit -m "graphics/test_port: not hooked into the build"
	[pre-commit] ERROR: Missing 'SUBDIR += test_port' in graphics/Makefile

This should hopefully help reduce the number of index breakages.

Differential Revision: https://reviews.freebsd.org/D34015
2022-04-13 05:29:33 +02:00
Mathieu Arnold
5147b3b5e1
.hooks/prepare-commit-msg: Enhance commit-msg hook.
If a single port is updated, the hook now pre-fills in an appropriate
subject line.
2021-06-04 13:57:25 +02:00
Mathieu Arnold
d744a8de42
.hooks/prepare-commit-msg: Cleanup.
Instead of writing everything in the new commit template all at once in
a large here document, do it cleanly one command at a time.
2021-06-04 13:57:19 +02:00
Mathieu Arnold
5b7c178565
git hooks: Rework authorship instructions.
While there, move them upwards so they are not hidden at the far end of
the template.
2021-04-22 11:50:30 +02:00
Mateusz Piotrowski
37dfa4eeea
git hooks: Adjust hooks for the ports tree
- Capitalize the topic line: this way the example is consistent with the
  desired style.
- Update the description of MFH.
- Point the Pull Request field to the ports repo on GitHub.

Reviewed by:	mat, bapt
Differential Revision:	https://reviews.freebsd.org/D29861
2021-04-22 11:48:22 +02:00
Mathieu Arnold
bbc2474ef7
Add the prepare-commit-msg hook to the repository.
To make use of it, the easiest way is to run:

  git config --add core.hooksPath .hooks

Discussed with:	bapt
2021-04-20 11:58:35 +02:00