diff --git a/README.md b/README.md index 13d4eb8..def1638 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/update b/update index 056fdab..e9eb3b8 100755 --- a/update +++ b/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