aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2023-11-16 18:06:46 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2023-11-17 03:46:57 +0100
commit4624214ab93829b9aa8d6cbac3de66488c22d324 (patch)
tree6d43046cea641176b99fce1563b210df32c8b426
parent3059ca5715aae40bd83433e0645cd100cf0321b2 (diff)
downloadpw-4624214ab93829b9aa8d6cbac3de66488c22d324.tar.gz
pw-apply: Emit a warning when applying too fresh patches
I tend to miss the fact that some series may be too fresh to be applied: let me get more help from the tool. Add mbox_from_series() the ability to warn if the series is not old as optionally specified, and set a default threshold of 24 hours for `pw-apply`. Add a command line argument (--min-age/-m) to allow setting a different threshold. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--lib.sh18
-rwxr-xr-xpw-apply4
2 files changed, 18 insertions, 4 deletions
diff --git a/lib.sh b/lib.sh
index ccb6b7c..c5ea818 100644
--- a/lib.sh
+++ b/lib.sh
@@ -32,15 +32,19 @@ pr_trunc_n()
fi
}
-date_to_age()
+date_to_hours()
{
local past="$1"
now=$(date +%s)
was=$(date -d "$past" +%s)
- hours=$(( (now - was) / (60 * 60) ))
+ echo $(( (now - was) / (60 * 60) ))
+}
+date_to_age()
+{
+ local hours=$(date_to_hours $1)
echo "$((hours / 24))d $((hours % 24))h"
}
@@ -70,6 +74,7 @@ pw_series_download_mbox()
pw_series_print_short()
{
local series_json="$1"
+ local min_age="$2"
series_subj=$(echo "$series_json" | jq -r '.name')
patch_subj=$(echo "$series_json" | jq -r '.patches[0].name')
@@ -103,6 +108,13 @@ pw_series_print_short()
echo "WARNING: Applying to the wrong tree?"
normal
fi
+ hours=$(date_to_hours "$date")
+ if [ -n "$min_age" -a $hours -lt $min_age ]; then
+ red
+ bold
+ echo "WARNING: series posted < ${min_age}h ago, have reviewers had enough time?"
+ normal
+ fi
echo "-----"
if [ "$cover_letter" != "null" ]; then
@@ -132,6 +144,6 @@ mbox_from_series()
series_json=$(curl -s $srv/series/$1/)
- pw_series_print_short "$series_json"
+ pw_series_print_short "$series_json" "$2"
pw_series_download_mbox "$series_json" mbox.i
}
diff --git a/pw-apply b/pw-apply
index 09ad057..747871e 100755
--- a/pw-apply
+++ b/pw-apply
@@ -103,6 +103,7 @@ cover_tags="y"
mb2q_normalize="y"
head_old=$(git rev-parse --verify HEAD)
base=""
+min_age=24
while true; do
case "$1" in
-3 ) am_flags="$am_flags -3"; shift ;;
@@ -111,6 +112,7 @@ while true; do
-e | --do-edits ) edits="1"; shift ;;
-N | --no-mb2q ) mb2q_normalize=""; am_flags="$am_flags -s"; shift ;;
-P | --no-merge ) no_merge="1"; shift ;;
+ -m | --min-age ) min_age="$2"; shift ;;
-M | --manual-merge) auto_branch=""; shift ;;
-b | --mbox ) mbox="$2"; shift 2 ;;
-u | --upstream-base ) base="$2"; shift 2 ;;
@@ -128,7 +130,7 @@ done
[ ! -z "$mbox" ] && [ ! -z "$series" ] && usage
[ -z "$mbox" ] && [ -z "$series" ] && [ -z "$cover" ] && usage
[ ! -z "$accept" ] && [ ! -z "$mbox" ] && usage
-[ ! -z "$series" ] && mbox_from_series $series
+[ ! -z "$series" ] && mbox_from_series $series $min_age
[ ! -z "$mbox" ] && mbox_from_url $mbox
[ ! -z "$accept" ] && accept_series $series
[ ! -z "$no_merge" ] && merge=