]> git.lizzy.rs Git - rust.git/blob - src/ci/scripts/should-skip-this.sh
Auto merge of #67312 - cuviper:clone-box-slice, r=SimonSapin
[rust.git] / src / ci / scripts / should-skip-this.sh
1 #!/bin/bash
2 # Set the SKIP_JOB environment variable if this job is supposed to only run
3 # when submodules are updated and they were not. The following time consuming
4 # tasks will be skipped when the environment variable is present.
5
6 set -euo pipefail
7 IFS=$'\n\t'
8
9 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
10
11 if [[ -z "${CI_ONLY_WHEN_SUBMODULES_CHANGED+x}" ]]; then
12     echo "Executing the job since there is no skip rule in effect"
13 elif git diff HEAD^ | grep --quiet "^index .* 160000"; then
14     # Submodules pseudo-files inside git have the 160000 permissions, so when
15     # those files are present in the diff a submodule was updated.
16     echo "Executing the job since submodules are updated"
17 else
18     echo "Not executing this job since no submodules were updated"
19     ciCommandSetEnv SKIP_JOB 1
20 fi