Re: what's the Correct git update method keeping local changes

From: Sysadmin Lists <sysadmin.lists_at_mailfence.com>
Date: Wed, 29 Mar 2023 02:53:12 UTC
> ----------------------------------------
> From: void <void@f-m.fm>
> Date: Mar 27, 2023, 8:19:19 PM
> To: <freebsd-hackers@freebsd.org>
> Subject: what's the Correct git update method keeping local changes
> 
> What's the best way?
> -- 
> 

I use the following interactive script to update and maintain local ports mods.
It updates the poudriere jail, switches branches when available, and merges
changes to my custom branch.

#!/usr/local/bin/bash
# update poudriere's ports git repos

jail_name="FreeBSD:13:amd64"
logfile="/usr/local/etc/poudriere.d/quarterly.log"
ports_dir="/usr/local/poudriere/ports/quarterly"
ports_list="[list of customized category/portname pairs goes here]"

curb=$(git -C $ports_dir branch | sed -n 'x;$p')

read -p "==> Update jails? [N|y] " update_jails
if [[ $update_jails == "y" ]]; then
        poudriere jail -uj $jail_name
fi

# prompt to switch branches if local quarter branch and current quarter differ
read month year <<< $(date "+%m %Y")
awk 'BEGIN { exit "'${curb: -1}'" == int(('$month' / 3) + .9) }' # (true is 1)
if [[ $? == 0 ]]; then
        read -p "==> Change branch? [n|Y] " change_branch
        if [[ ! $change_branch == "n" ]]; then
                set -ve
                newb=$(git -C $ports_dir branch -rl "*${year}Q*" | sed '$!d')
                git -C $ports_dir fetch
                git -C $ports_dir checkout ${newb#  origin/}
                git -C $ports_dir worktree list
                curb=${newb#  origin/}
                set +ve
        fi
fi

read -p "==> Update branches? [n|Y] " update_ports
if [[ ! $update_ports == "n" ]]; then
        set -ve
        poudriere ports -vup latest
        git -C $ports_dir checkout $curb
        poudriere ports -vup quarterly | tee $logfile
        git -C $ports_dir checkout custombranch
        git -C $ports_dir rebase $curb
        for port in $ports_list; do
                if grep --quiet $port $logfile; then
                        rsync -ax $ports_dir/$port/ \
                                $ports_dir/${port/*\//custom/}/
                fi
        done
        set +ve
fi

exit


-- 
Sent with https://mailfence.com  
Secure and private email