{"id":3327,"url":"https://patchwork.libcamera.org/api/patches/3327/?format=json","web_url":"https://patchwork.libcamera.org/patch/3327/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200326134821.8542-1-laurent.pinchart@ideasonboard.com>","date":"2020-03-26T13:48:21","name":"[libcamera-devel,v2] utils: hooks: Add pre-push commit hook","commit_ref":"36ad4eb188e078c9ec577213872febae57185646","pull_url":null,"state":"accepted","archived":false,"hash":"392d1ecaa13eb3d40c953465552212164b6fad55","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/3327/mbox/","series":[{"id":781,"url":"https://patchwork.libcamera.org/api/series/781/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=781","date":"2020-03-26T13:48:21","name":"[libcamera-devel,v2] utils: hooks: Add pre-push commit hook","version":2,"mbox":"https://patchwork.libcamera.org/series/781/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/3327/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/3327/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BDA5260410\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Mar 2020 14:48:30 +0100 (CET)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3BA312DC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 26 Mar 2020 14:48:30 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"HVdPGfQ5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1585230510;\n\tbh=bo1i5WpCbTj7GE5wn7X+qe45dwjm4L+rbfHBJ4XBaak=;\n\th=From:To:Subject:Date:From;\n\tb=HVdPGfQ5nGspE8/8isQJlbkWAnv9TxlRMGBvBPjaYY8FCHEMGoM6H+P5E//X5rAZ4\n\tDsU74U7N0Z1HyUOS0oGoAagwWgAVIrmDfwu0QNMAIkGClvKzoizaHmsi9ht4GQgpsw\n\ts+5gZHfV/qayocpKi1T6oaohJ+EPCgIrZSMtuwNM=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 26 Mar 2020 15:48:21 +0200","Message-Id":"<20200326134821.8542-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.24.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2] utils: hooks: Add pre-push commit hook","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 26 Mar 2020 13:48:31 -0000"},"content":"Add a pre-push commit hooks to prevent unintentional push of patches\ncontaining local changelogs to the master branch.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\nChanges since v1:\n\n- Fix shellcheck issues\n- Rewrite the description in the top comment\n- Remove dead or useless code\n---\n utils/hooks/pre-push | 43 +++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 43 insertions(+)\n create mode 100755 utils/hooks/pre-push","diff":"diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push\nnew file mode 100755\nindex 000000000000..099441b82ea6\n--- /dev/null\n+++ b/utils/hooks/pre-push\n@@ -0,0 +1,43 @@\n+#!/bin/sh\n+\n+# A hook script to prevent pushing unsuitable commits to the master branch.\n+# Unsuitable commits are commits that contain a local changelog below a '---'\n+# line. The criteria may get extended later.\n+#\n+# Information about the commits which are being pushed is supplied as lines to\n+# the standard input in the form:\n+#\n+#   <local ref> <local sha1> <remote ref> <remote sha1>\n+\n+z40=0000000000000000000000000000000000000000\n+\n+while read -r local_ref local_sha remote_ref remote_sha\n+do\n+\tif [ \"$remote_ref\" != refs/heads/master ]\n+\tthen\n+\t\tcontinue\n+\tfi\n+\n+\t# The remote master branch should never get deleted by this push, so we\n+\t# can assume that local_sha is not 0's. We may however be creating the\n+\t# remote branch, when pushing to a new empty repository for instance.\n+\tif [ \"$remote_sha\" = $z40 ]\n+\tthen\n+\t\t# New branch, examine all commits\n+\t\trange=\"$local_sha\"\n+\telse\n+\t\t# Update to existing branch, examine new commits\n+\t\trange=\"$remote_sha..$local_sha\"\n+\tfi\n+\n+\t# Find invalid commits.\n+\tcommit=$(git rev-list -n 1 --grep '^---' \"$range\")\n+\tif [ -n \"$commit\" ]\n+\tthen\n+\t\techo >&2 \"Found local changelog in $local_ref, not pushing\"\n+\t\techo >&2 \"Check commit $commit\"\n+\t\texit 1\n+\tfi\n+done\n+\n+exit 0\n","prefixes":["libcamera-devel","v2"]}