From owner-freebsd-git@freebsd.org Sat Nov 21 14:12:27 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 A2DD14681D4 for ; Sat, 21 Nov 2020 14:12:27 +0000 (UTC) (envelope-from dan@langille.org) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Cdb2y4Wn3z4mMt for ; Sat, 21 Nov 2020 14:12:26 +0000 (UTC) (envelope-from dan@langille.org) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 14B075C00AE; Sat, 21 Nov 2020 09:12:26 -0500 (EST) Received: from imap36 ([10.202.2.86]) by compute4.internal (MEProxy); Sat, 21 Nov 2020 09:12:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=langille.org; h= mime-version:message-id:in-reply-to:references:date:from:to:cc :subject:content-type; s=fm2; bh=jMkkZHsWiygjx6+r1OWuwJqXCIlUugQ sMIlFiV4FZv4=; b=DzHYv92GGUkHZRFHfpVSVOeV3HgW7sN/kGdWsc40ghjWSVR CJLO95z58Y+pnYwGvV3MdsM0YTG9ukWbF/6HzmAkNuHK0G6tnMlpT83NIGIqk3xw tZN1+UZPIbJRcEdrLSr8Oeth5+AHyhg5/P9q81AMiWEmiTzOh0glABh9KAHAHNzu bspbPw/Y5oawLFv638A9T3VjmLW1oYEEg4NaHwYetkFhcLbrG3NzgfR25L89VMkE UjAawH0NWIHC7F50Uob51q9170sA77Omc/Gugdu++lz4qAXeZwNbk9lrMlSKCaP5 IsuA6BtLsj/AJ3UI6L0LtDarimn0TPmJfeksRvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=jMkkZH sWiygjx6+r1OWuwJqXCIlUugQsMIlFiV4FZv4=; b=iB4pDSaeRAFtR5Sbb5KOKM +9/iVzLDpF4+hzm8v/hiyEnp7TBmVXuTIh3xB+5YWUs5+zVguN8Z7ikoCUO/Zqwl JiDVa1HwPQ0jzoPVBjnipwNwIaCnFY4Dc2oOm0OktjPIPa6xzMth8pmHfPaNAeo0 tpkO32Wqwdyc9QZEgzRG90srjnbhys4H3w6x8wKC6gq3OWl0YakfrxgHsoYbUHzO egUQBGHxFlt4pNK0VjtAKSRtzpx47ORiNn8pPOM5KTR5S68cci4R8kL96QmnWEkS FyOwZT6eV//h4DGVx6JCbo3MTNjLPtnfuUuOCLlSqXxGVBV8eG1958ORkh4Yd56Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudegvddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtsehttd ertderredtnecuhfhrohhmpedfffgrnhcunfgrnhhgihhllhgvfdcuoegurghnsehlrghn ghhilhhlvgdrohhrgheqnecuggftrfgrthhtvghrnhepleejudduvefhjefghedvffejte dvudfhfffghedtiefgueeljeetgfehkeeigeehnecuffhomhgrihhnpehsthgrtghkohhv vghrfhhlohifrdgtohhmpdhlohhnghgrihhrrdhnvghtnecuvehluhhsthgvrhfuihiivg eptdenucfrrghrrghmpehmrghilhhfrhhomhepuggrnheslhgrnhhgihhllhgvrdhorhhg X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id AF8F6188007F; Sat, 21 Nov 2020 09:12:25 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.3.0-622-g4a97c0b-fm-20201115.001-g4a97c0b3 Mime-Version: 1.0 Message-Id: <785f1386-f521-46d2-8e2e-a7c502fd943a@www.fastmail.com> In-Reply-To: <93aa2a3e-7e8a-8199-3feb-6e464a590d72@gmail.com> References: <197541CC-FEA7-4B4C-936E-66A5625BB64C@langille.org> <3c9f6285-ae7c-1062-2dd3-42f8c953a230@gmail.com> <93aa2a3e-7e8a-8199-3feb-6e464a590d72@gmail.com> Date: Sat, 21 Nov 2020 09:11:53 -0500 From: "Dan Langille" To: "Marc Branchaud" Cc: freebsd-git@freebsd.org Subject: Re: Monitoring commits on all branches Content-Type: text/plain X-Rspamd-Queue-Id: 4Cdb2y4Wn3z4mMt X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=langille.org header.s=fm2 header.b=DzHYv92G; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=iB4pDSae; dmarc=pass (policy=none) header.from=langille.org; spf=pass (mx1.freebsd.org: domain of dan@langille.org designates 66.111.4.25 as permitted sender) smtp.mailfrom=dan@langille.org X-Spamd-Result: default: False [-3.09 / 15.00]; XM_UA_NO_VERSION(0.01)[]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; R_SPF_ALLOW(-0.20)[+ip4:66.111.4.25]; RWL_MAILSPIKE_GOOD(0.00)[66.111.4.25:from]; RCVD_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[langille.org:+,messagingengine.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[langille.org,none]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; RCVD_IN_DNSWL_LOW(-0.10)[66.111.4.25:from]; RCVD_TLS_LAST(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[66.111.4.25:from]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:11403, ipnet:66.111.4.0/24, country:US]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[langille.org:s=fm2,messagingengine.com:s=fm1]; FREEFALL_USER(0.00)[dan]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; SPAMHAUS_ZRD(0.00)[66.111.4.25:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MID_RHS_WWW(0.50)[]; MAILMAN_DEST(0.00)[freebsd-git] 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: Sat, 21 Nov 2020 14:12:27 -0000 On Thu, Nov 19, 2020, at 5:30 PM, Marc Branchaud wrote: > On 2020-11-19 2:00 p.m., Dan Langille wrote: > > * How FreshPorts extracts data > > > > FreshPorts is only interested in a snapshot of the repo with respect > > to a given commit. It works on the 'repo as a whole' to extract > > values from the ports which were affected by that commit. Case in > > point: a commit to a parent port might affect any or all of the child > > ports. All the child ports need to be refreshed. > > I'm guessing that typically the child ports' stuff (in the ports tree) > does not change when the parent port changes. So you're talking about a > build-time or run-time dependency between ports? I imagine you have > some kind of ports-dependency database, which you can consult when a > particular port is changed. If the parent port change PORTVERSION, then make -V PORTVERSION on the child port probably changes value. The database entry for the child is updated to make sure it reflects what is now declared in the parent. All child ports are updated when a commit affects a parent port. > Or are you thinking git might be able to help you here? This is just background information as to why I need a snapshot (i.e. checkout a commit). > > I am quickly concluding that FreshPorts must decide in advance what > > git branches it will pay attention to. At present, it follows all > > branches. > > > > * FreshPorts (without git) uses email to create XML > > > > When moving FreshPorts from subversion to git, one of the goals was > > to avoid relying on email to know that a commit has occurred. That is > > how FreshPorts has always worked. The email (from the CVS commit) was > > parsed and XML created. This code was updated for SVN. The XML is > > then used to load the commit into the FreshPorts database which then > > drives the website contents. > > > > When I started the GIT conversion, there was no commit email. "git > > log $foo_hash...HEAD" is how FreshPorts knows what commits to > > process. > > > > One positive aspect of email approach: it identified the branch. So > > far, I can't see how I can process the repo as a whole and see every > > commit and know what branch it was on. > > You're right about that, but you *can* discover all the branches in the > repo (see below). > > > * Polling git > > > > It is beginning to sound like the FreshPorts git code for detecting > > incoming commits will be: > > > > Every N minutes, do this: > > > > for each repo in REPOS > > for branch in BRANCHES > > cd to the directory for that repo > git checkout branch > > git log $branch_last_hash...HEAD > > for each of those commits > > process the commit > > end for > end for > > end for > > That loops looks basically right. You'll need to "git fetch" in each > repo before processing branches. I was usually doing a git pull. I've been reading up on 'git pull' vs 'git fetch'. I think I will move to 'git fetch'. To reiterate: FreshPorts basically gets a read-only copy of the repo. It never does local mods. It just needs the files. It is similar to 'svn up' with never changing the files. An 'svn export' would be workable, but in practice, 'svn up' is faster. This is what I was reading: * https://stackoverflow.com/questions/292357/what-is-the-difference-between-git-pull-and-git-fetch * https://longair.net/blog/2009/04/16/git-fetch-and-merge/ > Watch out with that "git checkout branch" part: This is where a lot of > people get tripped up when they move from svn to git. It doesn't help > that git tries to do some hand-holding here, but really git users would > benefit from simply understanding how branch names are just labels for > commit SHA IDs. Without that understanding, people end up going down > the rabbit-hole that is the "git pull" command, a wretched hive of scum > and villainy if there ever was one. I understand the concern and I think I follow. Within the confines of 'only wanting the files for reference, never local modification', pull and fetch might be the same for me. I'll look at fetch more. > I'll just gloss over a lot of detail (but feel free to ask!) and > recommend that you work with the "origin/"-prefixed branch names. These > get updated every time you "git fetch" from the remote repo, and > basically behave as you'd expect. It's appropriate in your case, > because you're not creating any new commits. > > > At present, the REPOS and BRANCHES are: > > > > * freebsd BRANCHES="master branches/2020Q4 branches/2020Q3 branches/2020Q2 ...etc" > > * freebsd-ports BRANCHES="master stable/12 stable/11" > > * freebsd-doc BRANCHES="master" > > > > Some might ask: > > > > * Why not just master and latest-quarterly for freebsd-ports? > > * Because commits to older branches sometimes occur (or at least I > > thought I saw one once) > > > > Commit hooks might also help, but I'm not sure if that will make > > things easier or complicate everything > > Looking through the set of hooks ("git help hooks"), I don't see > anything that would help you. My idea for a hook: FreeBSD tells FreshPorts when a new commit arrives. FreshPorts wakes up and processes it. > > * When new branches arrive > > > > It is vital that FreshPorts remain automated as much as it can be. At > > present, under SVN, I might have to fix things perhaps 5 or 6 times a > > year, usually because a commit did not get processed. > > > > Keeping that in mind, I do not yet know how to handle the following > > situations: > > > > A new branch comes out. > > > > * Automation might be possible for ports quarterly branches > > * FreshPorts has to know there is a new branch > > Fundamentally you start by doing a "git fetch" to retrieve updates from > the official repository (you probably know that already, but I just want > to be pedantic). > > Then "git branch -r" will list all the remote ("origin/"-prefixed) > branches, including whatever new ones were just fetched. > > You can also do "git for-each-ref refs/remotes/origin" to see which > commit SHA ID corresponds to each remote branch name (though the branch > names are prefixed with "refs/remotes/origin/" not just "origin/"). You > might find its output easier to parse than the equivalent "git branch > -rv" suggested by Oliver. Thanks. > > * BRANCHES needs to be updated > > * I don't see that it can be automated for stable/* > > Instead of saving BRANCHES locally, just use the output of one of the > above commands every time you run the script. That way the list will > always be up to date. Yes, I think so too. > > > * need to handle 'git checkout branch' when branch does not exist? > > If you end up doing that, I'd say you're doing something wrong. Agreed. > > * Once branch exists, how do you find out about the commits when you have no > > starting point for 'git log'? > > Use "git merge-base" to find where the new branch split off from the > "master" or "main" branch. That is my starting commit for that branch? > > > Right now, a new quarterly branch is noticed when the first commit > > email comes through. FreshPorts then does an 'svn co' for that > > branch. > > > > I'm hoping someone has good ideas for my edge cases. > > I hope I've been a bit helpful! More than a bit. > One last, small idea: Consider using tags in your local repos to track > your $branch_last_hash. For example, after you finish processing the > 2020Q4 branch, do > git tag -f last-2020Q4 origin/branches/2020Q4 > Then the next time through the 2020Q4 branch you can start at the > "last-2020Q4" tag. For a new branch that doesn't have a tag yet, use > "git merge-base" to find the starting point. Tags in my local repos won't get things upset? If I lose the local repo.... -- Dan Langille dan@langille.org