I will be honest I had not looked at your instructions or bash functions yet. And each time there was a new Django security update, I needed to do some things manually in our fork.
This morning I just looked at them and adapted them for our fork. Well, I needed to run “brew install ripgrep” because I didn’t have “rg” installed on my mac, but apart from that, very nice indeed!
Thanks Ned for sharing the instructions and your gittree and gittreeif bash functions. Incredibly useful.
Recently we also had a django-debug-toolbar upgrade, so I further generalized the patch application steps:
# Define the branch to work on
export BRANCH=open-release/lilac.master
# What package are we upgrading? From what maj.min to what new version?
export PKG=Django OLDMAJ=2 OLDMIN=2 NEWVER=2.2.23
gittree git fetch --all
gittreeif origin/$BRANCH "git switch $BRANCH; git pull; git status -s -b"
gittreeif origin/$BRANCH git branch --set-upstream-to=origin/$BRANCH $BRANCH
# Eyeball the current state
gittreeif origin/$BRANCH -q pwd | while read d; do rg -i "^${PKG}==" -g '*.in' -g '*.txt' $d | sed 's/#.*//'; done
# Create a shell script to make the change
gittreeif origin/$BRANCH -q pwd | while read d; do rg -n -i "^${PKG}==${OLDMAJ}\.${OLDMIN}" -g '*.in' -g '*.txt' $d | awk -F: "{print \"sed -E -i '' '\" \$2 \"s/==${OLDMAJ}\\\\.${OLDMIN}(\\\\.[0-9]+)?/==$NEWVER/' \" \$1 \" # \" \$3}" ; done > /tmp/doit.sh
# Run the shell script
source /tmp/doit.sh
# Eyeball what the shell script did
gittreeif origin/$BRANCH git status -s -b
GIT_PAGER=cat gittreeif origin/$BRANCH git diff
# Commit the changes
gittreeif origin/$BRANCH git commit -am "chore: upgrade ${PKG} to ${NEWVER}"
gittreeif origin/$BRANCH git push
# Check that everything is clean.
gittreeif origin/$BRANCH git status -s -b
I’ve been working on applying the django patch to olive.master, but because I don’t have push rights to all repositories involved in the patch, I modified the above script to open PRs instead of pushing the change directly.