@@ -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+ git_user=${git_user:- os-autoinst-obs-workflow}
1617XMLSTARLET=$( command -v xmlstarlet || true)
1718[[ -n $XMLSTARLET ]] || (echo " Need xmlstarlet" >&2 && exit 1)
1819
@@ -175,6 +176,7 @@ update_package() {
175176 wait_for_package_build " $submit_target "
176177 for target in " ${targets[@]} " ; do
177178 [[ $target == none ]] && continue # allow specifying submit_target_extra=none for easier testing
179+ has_pending_submission " $package " " $target " && continue
178180 log-info " ## Ready to submit $package to $target ##"
179181 local submit_cmd=make_obs_submit_request
180182 local args=(" $package " " $target " " $version " )
@@ -279,16 +281,33 @@ get_project_packages() {
279281}
280282
281283has_pending_submission () {
282- log-info " has_pending_submission()"
283- local requestlist
284- # throttle number of submissions to allow only one SR within a certain number of days
285- # note: Avoid using `grep --quiet` here to keep consuming input so osc does not run into "BrokenPipeError: [Errno 32] Broken pipe".
284+ local package=$1 target=$2
285+ local git_branch=${git_branches[$target]:- }
286+ local requestlist is_older_than_throttle_days
287+ log-info " has_pending_submission($package , $target )"
288+
289+ # throttle number of submissions to allow only one PR or SR within a certain number of days
286290 [[ $throttle_days == 0 ]] && return 0
287- requestlist=$( $osc request list --project " $dst_project " --type submit --state new,review --mine --days " $throttle_days " )
288- if echo " $requestlist " | grep ' Created by' > /dev/null; then
289- log-info " Skipping submission, there is still a pending SR younger than $throttle_days days."
290- echo " $requestlist "
291- return 1
291+ if [[ $git_branch ]]; then
292+ # check for PR on Gitea
293+ is_older_than_throttle_days=$( $git_obs -q api " repos/pool/$package /pulls?state=open&sort=recentupdate" \
294+ | jq --arg days " $throttle_days " \
295+ --arg target " $git_branch " \
296+ --arg login " $git_user " \
297+ ' [.[] | select(.base.ref == $target) | select(.user.login == $login) | select(.updated_at | strptime("%Y-%m-%dT%H:%M:%S%z") | mktime > (now - ($days | tonumber) * 86400))] | length > 0' )
298+ if [[ $is_older_than_throttle_days != false ]]; then
299+ log-info " Skipping submission, there is still a pending PR by $git_user targeting $git_branch younger than $throttle_days days."
300+ return 1
301+ fi
302+ else
303+ # check for SR on OBS
304+ # note: Avoid using `grep --quiet` here to keep consuming input so osc does not run into "BrokenPipeError: [Errno 32] Broken pipe".
305+ requestlist=$( $osc request list --project " $target " --package " $package " --type submit --state new,review --mine --days " $throttle_days " )
306+ if echo " $requestlist " | grep ' Created by' > /dev/null; then
307+ log-info " Skipping submission, there is still a pending SR younger than $throttle_days days."
308+ echo " $requestlist "
309+ return 1
310+ fi
292311 fi
293312 return 0
294313}
@@ -306,7 +325,6 @@ submit() {
306325 cat job_post_skip_submission
307326 return 0
308327 fi
309- has_pending_submission || return 0
310328 (
311329 cd " $TMPDIR "
312330 rc=0
0 commit comments