From 20bde4f408311b65648794f35763a92d594f97b6 Mon Sep 17 00:00:00 2001 From: Ron Stone Date: Tue, 12 Apr 2022 07:35:29 -0400 Subject: [PATCH] Find missing cherry-picks (r5,r6,dsR6) Compare logs for two arbitrary branches by author and date range and filter for unmatched subject lines with pick notation e.g. (dsR6,r5). Signed-off-by: Ron Stone Change-Id: I45a1fe29f861fe8a749526a63a1f86d91efca3a3 --- .gitignore | 2 + pickCompare.sh | 260 +++++++++++++++++++++++++++++++++++++++++++++++++ tox.ini | 7 ++ 3 files changed, 269 insertions(+) create mode 100755 pickCompare.sh diff --git a/.gitignore b/.gitignore index 2d1e5978c..8eab2b90e 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,8 @@ instance/ # Sphinx documentation docs/_build/ +.pickOptions.sh + # API Reference Guide api-ref/build/ diff --git a/pickCompare.sh b/pickCompare.sh new file mode 100755 index 000000000..bcc797087 --- /dev/null +++ b/pickCompare.sh @@ -0,0 +1,260 @@ +#!/usr/bin/env bash + +RED='\033[0;31m' +GR='\033[0;32m' +NC='\033[0m' # No color + +today=$(date '+%Y-%m-%d') +default_start="2020-01-01" + +config_file=".pickOptions.sh" + +export COLUMNS=80 +IFS=$'\n' + +echo -e "`cat < /dev/null; then + echo -e "${RED}$edate is not valid. Try again.${NC}" + continue + else + declare -g ${date}=$edate + break + fi + ;; + + esac + done + done +} + +get_users () { + + echo -e "Select users\n" + + for auth in auth1 auth2 + do + + if [[ $auth == "auth1" ]]; then + repo=$br1 + else + repo=$br2 + fi + + echo -e "Optionally, select a ${GR}$repo${NC} author to filter by:\n" + + select os in $(git log --pretty=format:%an --after="$begin" --before="$end" $repo | sort | uniq; echo "None") + do + + case $os in + + None) + echo "No author selected, will show all authors." + declare -g ${auth}="" + break + ;; + *) + declare -g ${auth}="$os" + break + ;; + esac + done + # if [[ ${auth}=="" ]]; then break; fi + done +} + +get_pick () { + + read -p 'Optional string to filter on in (pick list): ' str + +} + +confirm_options () { + + read -n 1 -s -r -p "Press any key to continue or CTL-C to quit" + echo -e "\n\n" + +} + +compare_branches () { + + for pick in $({ git log --pretty=format:%s%n --after="$begin" --before="$end" --author="$auth1" $br1 & git log --pretty=format:%s%n --after="$begin" --before="$end" --author="$auth2" $br2; } | grep "(.*$str.*)$" | sort | uniq -u); do + echo -e "${RED}" $(git log --grep=$pick --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:"%cd, %s [ %h ]" --after=$begin --before=$end --author=$auth1 --author=$auth2 $br1 $br2) "${NC}" + done + +} + +save_settings () { + + echo -e "`cat < $config_file + + echo " ... saved" + + ;; + + *) + echo " ... not saved" + ;; + + esac + +} + +read_settings () { + + if [[ -f ${config_file} ]]; then + + echo -e "\nFound saved options:\n" + + values=$(<$config_file) + + values=${values/br1=/"First Branch: "} + values=${values/br2=/"Second Branch: "} + values=${values/auth1=/"First Author: "} + values=${values/auth2=/"Second Author: "} + values=${values/begin=/"Start Date: "} + values=${values/end=/"End Date: "} + values=${values/str=/"Pick Search String: "} + + echo -e "$values\n" + + read -p 'Reuse these options now? [y/n]: ' -n1 read_opts; + + case $read_opts in + + Y|y) + CONTEXT_DIR="${BASH_SOURCE%/*}" + if [[ ! -d "$CONTEXT_DIR" ]]; then CONTEXT_DIR="$PWD"; fi + . "$CONTEXT_DIR/$config_file" + echo " ... read" + ;; + *) + echo " ... not read" + ;; + esac + + fi +} + +read_settings + +if [ -z ${br1+x} ] || [ -z ${br2+x} ]; then get_branches; fi + +if [ -z ${begin+x} ] || [ -z ${end+x} ]; then get_dates; fi + +if [[ ! $read_opts == [yY] ]]; then + + get_users + get_pick + save_settings + +fi + +confirm_options +compare_branches diff --git a/tox.ini b/tox.ini index c164109f3..7f9798c1d 100644 --- a/tox.ini +++ b/tox.ini @@ -48,6 +48,13 @@ commands = whitelist_externals = new-topic.sh bash +[testenv:picks] +commands = + ./pickCompare.sh +whitelist_externals = pickCompare.sh + bash + + [testenv:linkcheck] deps = -r{toxinidir}/doc/requirements.txt