brizental pushed to branch base-browser-128.10.0esr-14.5-1 at The Tor Project / Applications / Tor Browser
Commits:
-
5d7a4431
by Beatriz Rizental at 2025-04-23T21:19:00+02:00
1 changed file:
Changes:
1 | 1 | .with-local-repo-bash:
|
2 | 2 | variables:
|
3 | 3 | GIT_STRATEGY: "none"
|
4 | + FETCH_TIMEOUT: 180 # 3 minutes
|
|
4 | 5 | before_script:
|
5 | 6 | - git init
|
6 | 7 | - git remote add local "$LOCAL_REPO_PATH"
|
... | ... | @@ -19,18 +20,38 @@ |
19 | 20 | exit 1
|
20 | 21 | fi
|
21 | 22 | - git fetch --depth 500 local $TARGET_BRANCH
|
23 | + - git --no-pager log FETCH_HEAD --oneline -n 5
|
|
22 | 24 | - git remote add origin "$CI_REPOSITORY_URL"
|
23 | 25 | - |
|
24 | 26 | if [ -z "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" ]; then
|
25 | 27 | echo "No branch specified. Stopping the pipeline."
|
26 | 28 | exit 1
|
27 | 29 | fi
|
28 | - - echo "Fetching from remote branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
|
|
30 | + - echo "Fetching from remote branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} with a ${FETCH_TIMEOUT}s timeout."
|
|
29 | 31 | - |
|
30 | - if ! git fetch origin "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"; then
|
|
31 | - echo -e "\e[31mFetching failed for branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} from $CI_REPOSITORY_URL.\e[0m"
|
|
32 | - echo "Attempting to fetch the merge request branch, assuming this pipeline is not running in a fork."
|
|
33 | - git fetch origin "merge-requests/${CI_MERGE_REQUEST_IID}/head"
|
|
32 | + fetch_with_timeout() {
|
|
33 | + local remote=$1
|
|
34 | + local branch=$2
|
|
35 | + |
|
36 | + set +e
|
|
37 | + timeout ${FETCH_TIMEOUT} git fetch "$remote" "$branch"
|
|
38 | + local fetch_exit=$?
|
|
39 | + set -e
|
|
40 | + |
|
41 | + if [ "$fetch_exit" -eq 124 ]; then
|
|
42 | + echo "Fetching failed for branch ${remote}/${branch} due to a timeout. Try again later."
|
|
43 | + echo "Gitlab may be experiencing slowness or the local copy of the repository on the CI server may be oudated."
|
|
44 | + return 1
|
|
45 | + fi
|
|
46 | + |
|
47 | + return $fetch_exit
|
|
48 | + }
|
|
49 | + |
|
50 | + if ! fetch_with_timeout origin "${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"; then
|
|
51 | + echo "Fetching failed for branch ${CI_COMMIT_BRANCH:-$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}."
|
|
52 | + echo "Attempting to fetch the merge request branch, assuming this pipeline is not running in a fork."
|
|
53 | + |
|
54 | + fetch_with_timeout origin "merge-requests/${CI_MERGE_REQUEST_IID}/head" || exit 1
|
|
34 | 55 | fi
|
35 | 56 | - git checkout FETCH_HEAD
|
36 | 57 |