FreshPorts - processing branches: help wanted
Dan Langille
dan at langille.org
Sat Apr 17 01:23:41 UTC 2021
Back in Nov mat wrote:
re: https://lists.freebsd.org/pipermail/freebsd-git/2020-November/000498.html
> From 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 at 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):
>
> #############################
> NAME_OF_REMOTE=origin
> NAME_OF_HEAD=main
>
> 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
>
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
>
> # 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 $(git 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.
The current solution is doing a 'git fetch'.
Now it's time to start doing branches.
Thank you.
--
Dan Langille - BSDCan / PGCon
dan at langille.org
More information about the freebsd-git
mailing list