Debian Codegraph @

.azure-pipelines/update-hashinfo

raw
1 #!/bin/bash -eu
2
3 echo "##[section]Setting up git configuration"
4 git config --global user.name "Azure on github.com/dials/data"
5 git config --global user.email "[email protected]"
6 git config credential.helper "store --file=.git/credentials"
7 echo "https://${GITHUB_TOKEN}:@github.com" > .git/credentials
8 echo
9
10 git checkout "${BUILD_SOURCEBRANCHNAME}"
11 CANDIDATE=$(echo ${BUILD_SOURCEBRANCHNAME} | cut -c 8-)
12 if [[ -z $CANDIDATE ]]; then
13 echo Could not determine dataset candidate to update
14 exit 1
15 fi
16
17 echo "##[section]Considering updating information on dataset ${CANDIDATE}"
18 for DATASET in $(dials.data list --quiet --missing-hashinfo)
19 do
20 if [[ "${DATASET}" == "${CANDIDATE}" ]]; then
21 echo "##[section]Updating dataset ${DATASET}"
22 dials.data get --create-hashinfo ${DATASET}
23 mv ${DATASET}.yml dials_data/hashinfo/${DATASET}.yml
24 if [ -z "$(git status --porcelain)" ]; then
25 echo Working directory remained clean. Something went wrong.
26 exit 1
27 fi
28 git add dials_data/hashinfo/${DATASET}.yml
29 echo
30 echo "##[section]Committing update"
31 git commit -m "Update file information for dataset ${DATASET}"
32 # Ensure dataset will not be downloaded again in the next round
33 dials.data list --quiet --missing-hashinfo | tee remaining-datasets
34 grep -- "^${DATASET}$" < remaining-datasets && {
35 echo Hashinfo sanity check failed
36 exit 1
37 }
38 git push
39 echo Success.
40 exit 0
41 fi
42 done
43
44 echo "##[error]Could not identify candidate to update. Something went wrong"
45 exit 1