From nobody Sun Apr 24 10:25:28 2022 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 24AEF199BF82; Sun, 24 Apr 2022 10:25:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KmPRY0PDwz4SDs; Sun, 24 Apr 2022 10:25:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650795929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lCj1LPbLEO5FvtCEomW6cwtg7yV93loZF22rC2fjncQ=; b=uC1KzVhr3zwkeV+ejvUAYdAeUFr8Uw72MukQKsOscTDjRyFbbL4DoJRt458WKw6LXHYxyR nYG/i9rcB+zVbXDozU0CQ6TFKoXeThqSh1LAXtG2z12ux6czlepnIuvwRENywJ4vS4ne9H zX8uCf6HFVC1/8X+S+DKYZ9yN7li4h4ODsxG2aUOl//BetA7oPLXR4e3BuD4PncsC3P4Au j0q361UNQsf2P92RKWn+JML81n4/Rp4dft8q09C2D+j1w4g6jeb9RnFocw9guLhAC6hDft HSgZFxtH9BBRNH8DfbRaSOK6bzHGddihQlwehic9Lqi/gxHMzOrbT2esHBMfjQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D439B244EF; Sun, 24 Apr 2022 10:25:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 23OAPSWT066117; Sun, 24 Apr 2022 10:25:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23OAPSuk066116; Sun, 24 Apr 2022 10:25:28 GMT (envelope-from git) Date: Sun, 24 Apr 2022 10:25:28 GMT Message-Id: <202204241025.23OAPSuk066116@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: "Tobias C. Berner" Subject: git: 4e21a051bb0a - main - framework: create a sub-directory to support multiple pre-commit hooks List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tcberner X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4e21a051bb0aa1e6ee77a30f5803d5ad6c49d578 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1650795929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lCj1LPbLEO5FvtCEomW6cwtg7yV93loZF22rC2fjncQ=; b=tTIscWukCBbzZb/HkbQi/9F9wMEFWnoVIfr5pQoTaCDUbzFCDJj2TW/kx5yaovxKCUm9ng bz0K3BNeaqkId4txz/vsKn0Z2sMOomOTDw5wNrcBpoITLPkWq9ZoMfOAUbRVQXYUFSZmoW HtQOPyA8csWjov5URV2YVSP2w7DhSUvrQU9mPU2ASLtUW5y0ejpfZZJ+GzIMy9mI8as5wl qJsR/RkDZWsHh04ssODFKKugmq3PjV1rFO7CEKOZ7m1mvu/22ffPnfpmXJdpC86SQNroNh 8/ewKRb3dPGLONG3D18LXKFIYcNlfRxkx/gKpzRHeHrnb9hR+lsVohHISnAYcg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1650795929; a=rsa-sha256; cv=none; b=AQyqPbGswdRAXpPtTIjoiCj19OloIZiIlRLBRwqAy7ttDH7PpnxncBnmQZTrqSmhOQps+F vnLgGw9A0OfTibRvfpX/6xh39DMa0Lq2k8XZ7N7qgHtGT/ZLUN5jsZzmmSzqa+28uO+W4A iBfgMHj8kI7eJK9pJ93FmjVNUSwitxsD+3tlLQZjIv4W8w2e1MDcQQnzRaYYoExq04xr8W QaXBxjpec0opj4TiFWAztkFEPkaTRT4PkNmut/vctRuA4fW+LJVE+5yGasXrzg+ou6HP2h ld2gUIRm5BetnWKrS5y8tXBxj2a8bt2s/2gJozKyuvIEnDxtW6cCVqszAmGIOA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tcberner: URL: https://cgit.FreeBSD.org/ports/commit/?id=4e21a051bb0aa1e6ee77a30f5803d5ad6c49d578 commit 4e21a051bb0aa1e6ee77a30f5803d5ad6c49d578 Author: Tobias C. Berner AuthorDate: 2022-04-24 10:11:13 +0000 Commit: Tobias C. Berner CommitDate: 2022-04-24 10:24:28 +0000 framework: create a sub-directory to support multiple pre-commit hooks --- .hooks/pre-commit | 18 ++++++++---------- .hooks/pre-commit.d/check_category_makefile | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/.hooks/pre-commit b/.hooks/pre-commit index fb43d4353256..886d97d7cc1b 100755 --- a/.hooks/pre-commit +++ b/.hooks/pre-commit @@ -1,17 +1,15 @@ #!/bin/sh # -# Check that ports are hooked into the build +# Runs every hook in pre-commit.d/ until the first failure # -newish_makefiles=$(git diff --name-only --cached --diff-filter=ACR | grep -E '^[^/]+/[^/]+/Makefile$') -if [ $? -eq 0 ] ; then - for newish_makefile in ${newish_makefiles} ; do - category=$(echo "${newish_makefile}" | awk -F '/' '{print $1}') - port=$(echo "${newish_makefile}" | awk -F '/' '{print $2}') - grep -q -E "^[[:space:]]+SUBDIR[[:space:]]\+=[[:space:]]*${port}\$" ${category}/Makefile +hook_directory=$(realpath $(dirname $0)) + +for hook in ${hook_directory}/pre-commit.d/* ; do + if [ -x "${hook}" ] ; then + ${hook} if [ $? -ne 0 ] ; then - echo "[pre-commit] ERROR: Missing 'SUBDIR += ${port}' in ${category}/Makefile" exit 1 fi - done -fi + fi +done diff --git a/.hooks/pre-commit.d/check_category_makefile b/.hooks/pre-commit.d/check_category_makefile new file mode 100755 index 000000000000..fb43d4353256 --- /dev/null +++ b/.hooks/pre-commit.d/check_category_makefile @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Check that ports are hooked into the build +# + +newish_makefiles=$(git diff --name-only --cached --diff-filter=ACR | grep -E '^[^/]+/[^/]+/Makefile$') +if [ $? -eq 0 ] ; then + for newish_makefile in ${newish_makefiles} ; do + category=$(echo "${newish_makefile}" | awk -F '/' '{print $1}') + port=$(echo "${newish_makefile}" | awk -F '/' '{print $2}') + grep -q -E "^[[:space:]]+SUBDIR[[:space:]]\+=[[:space:]]*${port}\$" ${category}/Makefile + if [ $? -ne 0 ] ; then + echo "[pre-commit] ERROR: Missing 'SUBDIR += ${port}' in ${category}/Makefile" + exit 1 + fi + done +fi