From owner-freebsd-git@freebsd.org Tue Nov 24 16:33:23 2020 Return-Path: Delivered-To: freebsd-git@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EC3622E98E6 for ; Tue, 24 Nov 2020 16:33:23 +0000 (UTC) (envelope-from mat@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (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 "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CgV2C6Ljvz4wG2; Tue, 24 Nov 2020 16:33:23 +0000 (UTC) (envelope-from mat@freebsd.org) Received: from mail.j.mat.cc (owncloud.cube.mat.cc [79.143.240.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mail.mat.cc", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: mat/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id B1D022C3D3; Tue, 24 Nov 2020 16:33:23 +0000 (UTC) (envelope-from mat@freebsd.org) Received: from aching.in.mat.cc (unknown [IPv6:2a01:678:42:0:bdf4:2e83:8ff:e8ad]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: mat@mat.cc) by mail.j.mat.cc (Postfix) with ESMTPSA id 70798942D84; Tue, 24 Nov 2020 16:33:21 +0000 (UTC) Date: Tue, 24 Nov 2020 17:33:20 +0100 From: Mathieu Arnold To: Dan Langille Cc: freebsd-git@freebsd.org Subject: Re: Monitoring commits on all branches Message-ID: <20201124163320.saytu6spw42v6fnd@aching.in.mat.cc> References: <197541CC-FEA7-4B4C-936E-66A5625BB64C@langille.org> <20201119085223.nsrp2e45oyepsvds@aching.in.mat.cc> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ntqidtvwvhfysqlt" Content-Disposition: inline In-Reply-To: X-BeenThere: freebsd-git@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Discussion of git use in the FreeBSD project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Nov 2020 16:33:24 -0000 --ntqidtvwvhfysqlt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 19, 2020 at 12:45:14PM -0500, Dan Langille wrote: > > On Nov 19, 2020, at 3:52 AM, Mathieu Arnold wrote: > >=20 > > On Wed, Nov 18, 2020 at 08:49:46PM -0500, Dan Langille wrote: > >> How can a repo be monitored for commits on all branches? > >>=20 > >> I know how to ask a given branch: do you have any commits after foo_ha= sh? > >>=20 > >> How do I: > >>=20 > >> * get a list of all commits since foo_hash > >=20 > > All commits on the branch foo_hash is: > >=20 > > git log $foo_hash...branch_name >=20 > So, branch_name, not HEAD as others have mentioned? >=20 > e.g. : git log $foo_hash..HEAD =46rom what I understood, freshports never needs to be able to access files on the top of a branch, it only needs to access the files on specific commits (the fact that a commit is at the top of the branch is only an artefact of the process). So, you never need to checkout any branches, you only need to checkout commits. So you never have a HEAD that points to a branch, HEAD is always in a detached state and points to a commit. So what you need to do is, git clone the repository, and then, each time the script runs, do (in somewhat shell script): ############################# NAME_OF_REMOTE=3Dorigin NAME_OF_HEAD=3Dmain cd /where/the/repo/is git fetch # get all references (so, branches, tags, and so one) and keep only # branches (named commits here) that the remote repository has git for-each-ref --format '%(objecttype) %(refname)' \ | sed -n 's/^commit refs\/remotes\///p' | while read -r type refname do # If we don't have the tag, it means we have not encountered the # branch yet. if ! git tag -l freshports/$refname then # get the first commit of that branch and create a tag. git tag -m "first known commit of $refname" -f freshports/$refname $(gi= t merge-base $NAME_OF_REMOTE/$NAME_OF_HEAD $refname) fi # Get the list of commits between the last known one and the tip of # the branch, list may be empty. git rev-list freshports/$refname..$refname | while read commithash do # checkout that commit (with -f so that if some file got changed, we # overwrite everything git checkout -f $commithash # process the commit done # Store the last known commit that we just processed. git tag -m "last known commit of $refname" -f freshports/$refname $refname done ############################# That's all, you never need to merge or pull or whatever else. > >=20 > >> * know which branch each of those commits was on (e.g. master, branche= s/2020Q4) > >=20 > > You will need to keep track of the latest commit on each branch > > separately, because there is absolutely no relation or ordering > > possible between branches. >=20 > Yes, I agree. FreshPorts is keeping track of the last commit on each bran= ch. >=20 > Thank you. --=20 Mathieu Arnold --ntqidtvwvhfysqlt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQKTBAABCgB9FiEEVhwchfRfuV0unqO5KesJApEdfgIFAl+9NcNfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDU2 MUMxQzg1RjQ1RkI5NUQyRTlFQTNCOTI5RUIwOTAyOTExRDdFMDIACgkQKesJApEd fgIejw/+K4i1Xzf+R1pcI4AevRitLSAxmppyYnAiuj8Vn6Ts3vtWam8pzHRJZObd DHFWqmtAbJRvPuPGVhssnW18ueWRCxpU4v/ue4SgWf3I428kaAOTf+Ic0pwhizIS 9SERfpis4Bp8BJLUzyqIMs0MBH1MSINXJREdW/HWDKfmpu/y3p2r4tpRo0Fo9ibW Z5r/eYg+mQC593weEiz27Wd30DGhhwfdPFh72qyuURiYnxnSIFs8VTTty9E0k/WP pfdiXIdyGmoRgTy93Pt0ThoiN/MpRQ250QcBQ3IuQg0z8ze0GLPzss1Hh3ru2+BJ 5Z0SeJMCb7v86QT4mSqVBmJrXAwJT1NmxtmnkWNvZ1OE9/QhjdRKNmNpH7XNbdDv Nq1NDN0RQ59guLayDorKF6Fm5f12eKkBpp7NJxu+/2GTGEEIldThpTSp/bv40LCR TPr3eWJyEOnDfIS6Xsiws7rEc+uP7a5H8rz2p+6tSJOYy608xWI/QohjipSlwrQc Z+TnPu7QVkzsuVI8nd2C2+9nk+FPmo88VIs2P30bp7WX45QAATy5YveV4jCK3J1h l/QEGask5U9KJd/HpQYE5hR64flUAIotC1FLfUjZ+N7zvqMTmZ0IA9yuIsBXQYLN ebxqeBlfEWJS/S3xkTEu3cvCU33vfdKZS1bwbQvY9ahgtVm8EuE= =1D7t -----END PGP SIGNATURE----- --ntqidtvwvhfysqlt--