-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare_gated
More file actions
executable file
·40 lines (37 loc) · 2.09 KB
/
Copy pathprepare_gated
File metadata and controls
executable file
·40 lines (37 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env bash
#
# Clone or fetch bare repos for all gated repositories.
# Extends ./prepare by cloning bare repos for all gated extensions and skins.
# Assumes ./prepare has been run first (needs ref/integration/config.git).
# PARALLEL=N clones/fetches N repos at a time (default: sequential).
#
# Usage: ./prepare_gated
# PARALLEL=1 ./prepare_gated
#
set -euo pipefail # exit on error, undefined vars, or pipe failures
. "$(dirname "$0")"/lib/setup # source shared setup (docker checks, shared vars, output capture, trace into the log)
. "$(dirname "$0")"/lib/clone_or_fetch # provides clone_or_fetch function
parallel="${PARALLEL:-0}" # PARALLEL=N clones N repos at a time; unset/0 = sequential (default)
# Build the list of Gerrit repos for all gated components.
# lib/build_component_list captures ./list_gated's output and checks its exit code —
# reading it via process substitution would swallow a non-zero exit, leaving repos[]
# empty and turning a broken config into a silent no-op run.
. "$(dirname "$0")"/lib/build_component_list # sets components[] from $1 or ./list_gated
# Convert each component path (e.g. "extensions/Echo") to its Gerrit repo ("mediawiki/extensions/Echo").
repos=() # array of Gerrit repo paths to clone or fetch
# ${components[@]+"${components[@]}"} is the bash 3.2-safe expansion under set -u (empty array -> no iterations).
for component in ${components[@]+"${components[@]}"}; do
repos+=("mediawiki/${component}") # += appends to a bash array
done
if [ "$parallel" -lt 1 ]; then
# --- Sequential mode (default) ---
# ${repos[@]+"${repos[@]}"} is the bash 3.2-safe expansion under set -u (empty array -> no iterations).
for repo in ${repos[@]+"${repos[@]}"}; do
clone_or_fetch "$repo"
done
else
# --- Parallel mode: clone/fetch $parallel repos at a time (lib/run_waves) ---
items=(${repos[@]+"${repos[@]}"}) # lib/run_waves processes this ambient items[] array
_run_waves_job() { clone_or_fetch "$1"; } # worker: clone or fetch one repo ($1 = Gerrit repo path)
. "$(dirname "$0")"/lib/run_waves # launch the jobs, throttled to $parallel at a time
fi