Skip to content

Instantly share code, notes, and snippets.

@sanchezl
Last active September 7, 2022 16:49
Show Gist options
  • Save sanchezl/891bedcbf78390460a1706015594e7e2 to your computer and use it in GitHub Desktop.
Save sanchezl/891bedcbf78390460a1706015594e7e2 to your computer and use it in GitHub Desktop.
List OpenShift patches for upstream that need to be rebased onto the latest upstream.
#!/usr/bin/env bash
openshiftMasterRef="openshift/master"
kubernetesRef="v1.25.0"
mergeBase=$(git merge-base ${openshiftMasterRef} ${kubernetesRef})
# Generates a list (tab separated values) of the OpenShift commits
# that will need to be rebased onto the target kubernetes version.
#
# Assumes the following steps have already been executed in your
# local clone of openshift/kubernetes and you have fetched the
# kubernetes/kubernetes repo as a remote.
#
# Create a new local branch from upstream to rebase onto:
#
# git checkout -b rebase-${kubernetesRef} ${kubernetesRef}
#
# Merge openshift patches into the local branch, without actually
# accepting any changes:
#
# git merge -s ours ${openshiftMasterRef}
hyperlink() {
printf "=HYPERLINK(\"%s\",\"%s\")" "$1" "$2"
}
linkToCommit() {
hyperlink "https://github.com/openshift/kubernetes/commit/$1" "$1"
}
linkToPR() {
[ -n "$1" ] && hyperlink "https://github.com/kubernetes/kubernetes/pull/$1" "PR $1"
}
mapfile -t logs < <( \
git log $(git merge-base "${openshiftMasterRef}" "${kubernetesRef}" )..${openshiftMasterRef} \
--ancestry-path \
--reverse \
--no-merges \
--oneline \
| grep 'UPSTREAM:' \
)
printf "Summary\tCommit\tUpstream PR\tAction\tClean\tVerification\tSIG\tComments\n"
for log in "${logs[@]}" ; do
hash="${log%% *}"
summary="${log#* }"
upstreamPR=$(sed -E 's/UPSTREAM: ([0-9]*).*/\1/' <<< ${summary})
printf "%s\t%s\t%s\t\t\t\t\t\n" \
"${summary}" \
"$(linkToCommit $hash)" \
"$(linkToPR $upstreamPR)"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment