@@ -13,6 +13,7 @@ dry_run="${dry_run:-"0"}"
1313osc_poll_interval=" ${osc_poll_interval:- 2} "
1414osc_build_start_poll_tries=" ${osc_build_start_poll_tries:- 30} "
1515throttle_days=${throttle_days:- 2}
16+ throttle_days_leap_16=${throttle_days_leap_16:- 7}
1617git_user=${git_user:- os-autoinst-obs-workflow}
1718XMLSTARLET=$( command -v xmlstarlet || true)
1819[[ -n $XMLSTARLET ]] || (echo " Need xmlstarlet" >&2 && exit 1)
@@ -30,6 +31,11 @@ declare -A git_branches=(
3031 [' openSUSE:Leap:16.0' ]=leap-16.0
3132)
3233
34+ # allow specifying target-specific throttle variables
35+ declare -A throttle_variables=(
36+ [' openSUSE:Leap:16.0' ]=throttle_days_leap_16
37+ )
38+
3339encode_variable () {
3440 # https://stackoverflow.com/a/298258
3541 perl -MURI::Escape -e ' print uri_escape($ARGV[0])' " $1 "
@@ -281,32 +287,33 @@ get_project_packages() {
281287}
282288
283289has_pending_submission () {
284- [[ $throttle_days == 0 ]] && return 0
285-
286290 local package=$1 target=$2
287291 local git_branch=${git_branches[$target]:- }
292+ local throttle_variable=${throttle_variables[$target]:- throttle_days}
293+ local throttle_days_value=${! throttle_variable:- 0}
288294 local requestlist recent_pr_url
295+ [[ $throttle_days_value == 0 ]] && return 0
289296 log-info " has_pending_submission($package , $target )"
290297
291298 # throttle number of submissions to allow only one PR or SR within a certain number of days
292299 if [[ $git_branch ]]; then
293300 # check for PR on Gitea
294301 recent_pr_url=$( $git_obs -q api " repos/pool/$package /pulls?state=open&sort=recentupdate" 2> /dev/null \
295302 | jq --raw-output \
296- --arg days " $throttle_days " \
303+ --arg days " $throttle_days_value " \
297304 --arg target " $git_branch " \
298305 --arg login " $git_user " \
299306 ' [.[] | select(.base.ref == $target) | select(.user.login == $login) | select(.updated_at | strptime("%Y-%m-%dT%H:%M:%S%z") | mktime > (now - ($days | tonumber) * 86400)) | .html_url] | first' )
300307 if [[ $recent_pr_url != null ]]; then
301- log-info " Skipping submission, there is the still pending PR '$recent_pr_url ' by $git_user targeting $git_branch younger than $throttle_days days."
308+ log-info " Skipping submission, there is the still pending PR '$recent_pr_url ' by $git_user targeting $git_branch younger than $throttle_days_value days."
302309 return 1
303310 fi
304311 else
305312 # check for SR on OBS
306313 # note: Avoid using `grep --quiet` here to keep consuming input so osc does not run into "BrokenPipeError: [Errno 32] Broken pipe".
307- requestlist=$( $osc request list --project " $target " --package " $package " --type submit --state new,review --mine -- days " $throttle_days " )
308- if echo " $requestlist " | grep ' Created by ' > /dev/null; then
309- log-info " Skipping submission, there is still a pending SR for package $package in project $target younger than $throttle_days days."
314+ requestlist=$( $osc request list --project " $dst_project " --package " $package " --type submit,maintenance_incident --state new,review --days " $throttle_days_value " )
315+ if echo " $requestlist " | grep --fixed-strings " $target " > /dev/null; then
316+ log-info " Skipping submission, there is still a pending SR for package $package in project $target younger than $throttle_days_value days."
310317 echo " $requestlist "
311318 return 1
312319 fi
0 commit comments