From nobody Tue Nov 15 18:21:46 2022 X-Original-To: dev-commits-ports-main@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 4NBZJW2CTDz4hQBg; Tue, 15 Nov 2022 18:21:47 +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 4NBZJV6WPYz4B6V; Tue, 15 Nov 2022 18:21:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668536506; 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=gE2JBbIglmTgRqZLZx9ZuIou1I/CfdWDmSQa8KKSrsE=; b=c+7mnpbrdQnewhaiU9o8/rsHNwc0i4m2mtqpFNI0qNj/V0ekbhdmtYm9OBrDzScD2C/xYI 4uprVmAdgVCvLotfYxgnhDWBI+oySGk2t1S0Bdopd74q3dp3pA+VKpyy/474AFW/id6oT9 EcvNDOFhRCWj2S+OhNOgxzS8Y17iJuInQ6O5tRjCFJIKEwRyb+5P/vNRvOxqeGIynTalrG yIR20qy7nxYFj5Fi4tvYHt4PsLbwGQW6GD/fw2Hsh2sACyFDxRyM8i7JZwmGbuRfZ8QRUd fFk2Nmt/b3osBRp2utQjdAt2o4sXLQUon9VvzlgIu1p0m22h+zH5DySY9UWMkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668536506; 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=gE2JBbIglmTgRqZLZx9ZuIou1I/CfdWDmSQa8KKSrsE=; b=Bi+pC1lIuySHibFSIfOORVIQeIS330oijjst6oYrHIFoyuQbR77il5uxke45dl0UV7PIN4 MPzdZrG/B+wNOUJPCpLxc80jeg+xzg4004aIx6mDp0ddM6d3JByidoR+QK8GOtRBIE17Zk js4DkvOHLHZrl335jCWqvs9K02n1e7rAeb9fAmGe80N93p+/0zDmeI3HO2XlIRyaPEQvXY sXNrn9ZL/9S8I3Mq28C2vhZN4uPMEg4HdL/xAlMpQe0QsijETlx/IlDz/LoJWGG9lfGQLn xp5qWdWNOuEm6WGm0Mbl5Q2+JuoTH3e85POrDnv5g2C/jb1HlxtSERpND9NQAQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668536506; a=rsa-sha256; cv=none; b=nIjirT6Qz+ZKR/qw84cZBrt1X3rlKfCEtQThkq8klvzg95S7Zo47HcgF43W1iUiWMiGeWy Ih1bdnocsNGz0Fsg12DVmWInM0m4Z/erin0tss+sJRVVFqXl8tlq+xDWa9AedObvBLZPMo 6NMA1LttCJcOiwiSQDxgMGP2ytsZdKG8m1I2GcbyWvtpI2sWyOejmIazRHzFvR4ngqbWm1 YncZR2LURwAOplTGzVThqtF2FAfS6AuHYzquni4MNIv/Avm7vhgo2dNliosVsAG2qzaRtV lwJEVZxrvXM3w0DLs6mTrbhrXsQzBsmH+4fQD903/7wMVQlnRcTxC8JznDZp8Q== 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 4NBZJV5ZpyzXcl; Tue, 15 Nov 2022 18:21:46 +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 2AFILkpp082074; Tue, 15 Nov 2022 18:21:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AFILk3h082073; Tue, 15 Nov 2022 18:21:46 GMT (envelope-from git) Date: Tue, 15 Nov 2022 18:21:46 GMT Message-Id: <202211151821.2AFILk3h082073@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: 537c7c00047f - main - framework: new hook to only allow 'default' files in category/port List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@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: 537c7c00047fd4ba18247c3e160529f697f7d1a2 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by tcberner: URL: https://cgit.FreeBSD.org/ports/commit/?id=537c7c00047fd4ba18247c3e160529f697f7d1a2 commit 537c7c00047fd4ba18247c3e160529f697f7d1a2 Author: Tobias C. Berner AuthorDate: 2022-11-14 18:34:18 +0000 Commit: Tobias C. Berner CommitDate: 2022-11-15 18:20:27 +0000 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 --- .hooks/pre-commit.d/check_files | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.hooks/pre-commit.d/check_files b/.hooks/pre-commit.d/check_files new file mode 100755 index 000000000000..01eae4f2b3d8 --- /dev/null +++ b/.hooks/pre-commit.d/check_files @@ -0,0 +1,30 @@ +#!/bin/sh +# +# Check that only standard files are added to a port +# +# .*\.mk +# Makefile.* +# distinfo.* +# pkg-.* +# + +category_regex="($(make -VSUBDIR | sed 's# #\|#g'))" +newish_files=$(git diff --name-only --cached --diff-filter=ACR | grep -E "^${category_regex}/[^/]+/[^/]+$") + +status=0 +if [ $? -eq 0 ] ; then + for newish_file in ${newish_files} ; do + category=$(echo "${newish_file}" | awk -F '/' '{print $1}') + port=$(echo "${newish_file}" | awk -F '/' '{print $2}') + file=$(echo "${newish_file}" | awk -F '/' '{print $3}') + valid=$(echo "${file}" | grep -q '^((Makefile|distinfo|pkg-)(.*))|(.*\.mk)$') + if [ $? -ne 0 ] ; then + echo "[pre-commit] ERROR: invalid file '${file}' in '${category}/${port}'" + status=1 + fi + done +fi +if [ ${status} -eq 1 ] ; then + echo " Consider moving non-standard files to files/ or force-ignore this hook." + exit 1 +fi