[MacPorts] #52770: Git: pre-commit hook for 'port lint' if a Portfile is about to be committed (was: Git: pre-commit-hook could run "port lint" if a Portfile is about to be committed by the user...)
MacPorts
noreply at macports.org
Fri Mar 23 15:30:21 UTC 2018
#52770: Git: pre-commit hook for 'port lint' if a Portfile is about to be committed
-----------------------------+---------------------
Reporter: mkae | Owner: admin@…
Type: enhancement | Status: new
Priority: Normal | Milestone:
Component: server/hosting | Version: 2.3.4
Resolution: | Keywords:
Port: |
-----------------------------+---------------------
Comment (by raimue):
As a start, here is an example pre-commit hook that runs `port lint` on
all Portfiles in the staged state as they are about to be committed. Put
this into `macports-ports/.git/hooks/pre-commit` and make it executable
with `chmod +x`.
{{{
#!/bin/bash
portdirs=$(git diff --staged --name-only --diff-filter=d | sed
'/Portfile$/!d;s/^\(.*\)\/Portfile$/\1/')
if [ -n "$portdirs" ]; then
git stash push -q --keep-index
port lint $portdirs
git stash pop -q
fi
exit 0
}}}
This will not reject the commit on warnings or errors, it merely puts out
informative messages. Of course this adds a slight delay to the commit
process with lots of ports, but `port lint` is usually fast and it can
also be skipped with `git commit --no-verify`.
Should we keep such hooks in the repository? Or should we keep them in the
documentation, for example [wiki:CommitterDocs]?
--
Ticket URL: <https://trac.macports.org/ticket/52770#comment:9>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list