[{"id":4447,"web_url":"https://patchwork.libcamera.org/comment/4447/","msgid":"<20200414220230.GA428553@oden.dyn.berto.se>","date":"2020-04-14T22:02:30","subject":"Re: [libcamera-devel] [PATCH v2] utils: hooks: Add pre-push commit\n\thook","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2020-03-26 15:48:21 +0200, Laurent Pinchart wrote:\n> Add a pre-push commit hooks to prevent unintentional push of patches\n> containing local changelogs to the master branch.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nFinally found to test this patch, nice work it will relive some anxiety \nwhen I try to improve my workflow by writing more changelogs.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n> Changes 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\n> \n> diff --git a/utils/hooks/pre-push b/utils/hooks/pre-push\n> new file mode 100755\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x244.google.com (mail-lj1-x244.google.com\n\t[IPv6:2a00:1450:4864:20::244])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE7F360406\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Apr 2020 00:02:32 +0200 (CEST)","by mail-lj1-x244.google.com with SMTP id q22so1554550ljg.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 14 Apr 2020 15:02:32 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\ti20sm11527558lfe.15.2020.04.14.15.02.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 14 Apr 2020 15:02:31 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com header.b=\"okKgarXm\"; \n\tdkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=Yr0M473mPHSoXFx5jjvlYViOCrF6ywCorwzZH64FO/k=;\n\tb=okKgarXmjvMjtq6skqJK0vBnElIlBx1N53C8jyE31rmVX6aHH+LmhGnYz3Iru7jjbk\n\tQdo6vl3A/0KqWLhGHZXoUlyhLKvPyEdQ+JV6kK05LUiGygYgOmYeyNfH/grNbY1c7xVp\n\tifRIF0HVnHiCxfXB1pKEVADpMa7z2SslUYBbgw8QRetyYeT08bW7auHUezypN3L+j5O4\n\t5LWR304itpJ7etxuRZCfnv8E2AreIbfUCkpeyhQDfrHlzJkRpIgMJp4uDcuZlHz8GBFi\n\tXzjT/aQlJqoxE5YDi+lNkWAe1gPNWh5lglyrJlGvuo2Pnv9FzNYl8AIOs8KDYHzxD2bn\n\tD5dQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=Yr0M473mPHSoXFx5jjvlYViOCrF6ywCorwzZH64FO/k=;\n\tb=ijmT/YI4a6XVSm3mfh3NQgD+qVHmKinr4VJG0Cc+QaE3zzS6hg1Z0nTgA+X0d9utd/\n\tPGbKzocotIqLKopNSsGaopelv4lzAnt8R6QX6qiIpWslgLl7X3rzxDaKqmUx2JIFR3v3\n\tdCNLyWTnCsAHXFdMFV+s3vxI/srCQPCcKO8B2znmBIl2aXstTw7UnGoOyalXnUEJBUC2\n\tHTlinsd97Gi1fMSdGFVDJ+IuS13I5RR8x4w5RAX3zSNXXlf+PwA0vUmOlg9UOogjIyC6\n\t8bS8WpgziXZ4VFYjJRE2wihNHwElFNjOJsUWh++gWnqhk30FWazJ4XX+NRldkf99xs10\n\tN+KQ==","X-Gm-Message-State":"AGi0PubmAKxdmudVSTAJDPp2FgepHJvJ36PCONHKNI22sndYtkw90o/v\n\thzh3UvXJA4S/kdJZ39+P401GnQ==","X-Google-Smtp-Source":"APiQypLmYJcvLsV24JjCG4krRPLVUEZg8wFy3JZmcoeRNqpsnc+4d+xX8NYAB0LomHKkH5gWxo2r3A==","X-Received":"by 2002:a2e:1616:: with SMTP id w22mr510290ljd.261.1586901751812;\n\tTue, 14 Apr 2020 15:02:31 -0700 (PDT)","Date":"Wed, 15 Apr 2020 00:02:30 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200414220230.GA428553@oden.dyn.berto.se>","References":"<20200326134821.8542-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20200326134821.8542-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2] utils: hooks: Add pre-push commit\n\thook","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":"Tue, 14 Apr 2020 22:02:33 -0000"}}]