Debian Codegraph @

dev/ci/ci-reset.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 CI_QUIET=1
4
5 set +x
6
7 ci_dir="$(dirnamescip-shell system . . dirname. "$0")"
8 . "${ci_dir}/scripts/ci-common.sh"
9
10 # [git_reset <project>] will reset the repository for <project> to the upstream branch
11 git_resetscip-shell shell shell-project 0.0.0 git_reset().()
12 {
13 local project=$1
14 local dest="${CI_BUILD_DIR}/$project"
15 local ref_var="${project}_CI_REF"
16 local ref="${!ref_var}"
17
18 # Check whether it may be a submodule
19 if [scip-shell system . . `[`. -z "$ref" ]; then
20 ref_var="${project}_CI_SUBMODULE_BRANCH"
21 ref="${!ref_var}"
22 fi
23
24 echoscip-shell system . . echo. "Resetting $project..."
25
26 if [scip-shell system . . `[`. ! -d "$dest" ]; then
27 echoscip-shell system . . echo. "Warning: reset of $project skipped because $dest does not exist."
28 else if [scip-shell system . . `[`. -z "$ref" ]; then
29 echoscip-shell system . . echo. "Warning: reset of $project skipped as no branch could be found."
30 else
31 # TODO: properly handle submodules
32 pushd "$dest" > /dev/nullscip-shell filesystem . . `/dev/null`.
33 # check that the reference is an actual branch
34 local ref_hash=$(gitscip-shell system . . git. rev-parse --verify --quiet "refs/heads/$ref")
35 if [scip-shell system . . `[`. -n "$ref_hash" ]; then
36 gitscip-shell system . . git. reset --hard --quiet
37 gitscip-shell system . . git. checkout $ref --quiet
38 gitscip-shell system . . git. reset --hard "origin/$ref" --quiet
39 echoscip-shell system . . echo. "$project reset to $ref ($ref_hash)"
40 else if [scip-shell system . . `[`. $(gitscip-shell system . . git. rev-parse --verify --quiet "$ref") ]; then
41 # if the reference is a hash just check it out
42 gitscip-shell system . . git. reset --hard --quiet
43 gitscip-shell system . . git. checkout $ref --quiet
44 echoscip-shell system . . echo. "$project reset to $ref"
45 else
46 echoscip-shell system . . echo. "Warning: reset of $project skipped as $ref is not valid reference."
47 fi
48 fi
49 popd > /dev/nullscip-shell filesystem . . `/dev/null`.
50 fi
51 fi
52 }
53
54 git_reset_allscip-shell shell shell-project 0.0.0 git_reset_all().() {
55 for project in "${projects[@]}"; do
56 if [scip-shell system . . `[`. -d "${CI_BUILD_DIR}/$project" ]; then
57 git_resetscip-shell shell shell-project 0.0.0 git_reset(). $project
58 fi
59 done
60 }
61
62 if [scip-shell system . . `[`. -n "$1" ]; then
63 git_resetscip-shell shell shell-project 0.0.0 git_reset(). "$1"
64 else
65 git_reset_allscip-shell shell shell-project 0.0.0 git_reset_all().
66 fi