Date: Tue, 24 Nov 2020 17:33:20 +0100 From: Mathieu Arnold <mat@freebsd.org> To: Dan Langille <dan@langille.org> Cc: freebsd-git@freebsd.org Subject: Re: Monitoring commits on all branches Message-ID: <20201124163320.saytu6spw42v6fnd@aching.in.mat.cc> In-Reply-To: <EF8F4764-3C26-4BAB-9B1E-E0686A675E20@langille.org> References: <197541CC-FEA7-4B4C-936E-66A5625BB64C@langille.org> <20201119085223.nsrp2e45oyepsvds@aching.in.mat.cc> <EF8F4764-3C26-4BAB-9B1E-E0686A675E20@langille.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <mat@FreeBSD.org> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20201124163320.saytu6spw42v6fnd>