add additional check for empty pad
This commit is contained in:
parent
6423d1dc04
commit
e1ecb7dc05
2 changed files with 18 additions and 13 deletions
|
@ -8,4 +8,4 @@ include:
|
|||
file: 'lib/gitlab-ci.yml'
|
||||
```
|
||||
|
||||
The including CI configuration has to provide a `CI_ACCESS_TOKEN` that can push to the repo.
|
||||
The project including the CI configuration has to provide the variable `CI_ACCESS_TOKEN`. It must contain a project access token that can push to the repo.
|
||||
|
|
29
update
29
update
|
@ -8,20 +8,24 @@ update() {
|
|||
|
||||
curl --silent -k -o "${dst}" "${url}/export/txt"
|
||||
status="$?"
|
||||
|
||||
if [ ${status} -ne 0 ]; then
|
||||
echo "Failed to get pad at ${url}"
|
||||
else
|
||||
git -C "${gitdir}" add "${dst}"
|
||||
changes=$(git -C "${gitdir}" diff --cached | wc -l)
|
||||
if [ "$changes" -gt 0 ]; then
|
||||
git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}"
|
||||
else
|
||||
echo "Nothing changed for ${url}"
|
||||
fi
|
||||
echo "Failed to get pad at ${url}"
|
||||
return
|
||||
fi
|
||||
|
||||
newlength="$(wc -l ${dst})"
|
||||
if [ "$newlength" -lt 3 ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
git -C "${gitdir}" add "${dst}"
|
||||
changes=$(git -C "${gitdir}" diff --cached | wc -l)
|
||||
if [ "$changes" -gt 0 ]; then
|
||||
git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}"
|
||||
else
|
||||
echo "Nothing changed for ${url}"
|
||||
fi
|
||||
|
||||
git -C "${gitdir}" reset --hard HEAD
|
||||
}
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree
|
||||
|
@ -33,4 +37,5 @@ fi
|
|||
while read -r pad
|
||||
do
|
||||
update "$pad"
|
||||
git -C "${gitdir}" reset --hard HEAD
|
||||
done
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue