Date: Fri, 16 Apr 2021 21:08:23 -0400 From: Dan Langille <dan@langille.org> To: freebsd-git@freebsd.org Subject: FreshPorts - processing branches: help wanted Message-ID: <35888E09-CF1B-42AD-98B4-3792A0458912@langille.org>
next in thread | raw e-mail | index | archive | help
Back in Nov mat wrote: re: = https://lists.freebsd.org/pipermail/freebsd-git/2020-November/000498.html > =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. Yes. This is the current state on production: [dan@ingress01:/var/db/freshports/ports-jail/var/db/repos/ports] $ git = status HEAD detached at 9d5f4ef1a469 nothing to commit, working tree clean > So what you need to do is, git clone the repository, and then, each = time > the script runs, do (in somewhat shell script): >=20 > ############################# > NAME_OF_REMOTE=3Dorigin > NAME_OF_HEAD=3Dmain >=20 > cd /where/the/repo/is >=20 > git fetch >=20 > # get all references (so, branches, tags, and so one) and keep only > # branches (named commits here) that the remote repository has >=20 If I want to follow a new remote branch, I have to first do: git = checkout <branchname> ? This makes some sense to me, but this late in the day, I can't follow = it. I'm hoping someone is willing to follow up on this suggestion and = proceed with coding. It doesn't depend upon having a FreshPorts environment at all. Thank you. > git for-each-ref --format '%(objecttype) %(refname)' \ > | sed -n 's/^commit refs\/remotes\///p' > | while read -r type refname > do >=20 > # If we don't have the tag, it means we have not encountered the > # branch yet. > if ! git tag -l freshports/$refname > then >=20 > # get the first commit of that branch and create a tag. > git tag -m "first known commit of $refname" -f freshports/$refname = $(git merge-base $NAME_OF_REMOTE/$NAME_OF_HEAD $refname) > fi >=20 > # 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 >=20 > # process the commit > done >=20 > # Store the last known commit that we just processed. > git tag -m "last known commit of $refname" -f freshports/$refname = $refname > done > ############################# >=20 > That's all, you never need to merge or pull or whatever else. The current solution is doing a 'git fetch'. Now it's time to start doing branches. Thank you.=20 --=20 Dan Langille - BSDCan / PGCon dan@langille.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?35888E09-CF1B-42AD-98B4-3792A0458912>