gitlab-ci: if running on a fork, only check the files in the fork

To avoid confusing newbies, the CI should only run on the files that were
changed in the fork.  Sometimes lint/rewrite errors slip into the git repo,
and the CI for all merge requests will fail until those are fixed.  This
changes that to make the merge request CI only fail if the files in the
merge request are the ones with problems.

The CI runs on the main repo should will check everything.
master
Hans-Christoph Steiner 2018-01-22 11:56:28 +01:00
parent f2a2940a97
commit fed1acd8f6
1 changed files with 14 additions and 3 deletions

View File

@ -8,13 +8,24 @@ before_script:
lint:
script:
# if this is a merge request fork, then only check relevant apps
- if [ "$CI_PROJECT_NAMESPACE" != "fdroid" ]; then
git fetch https://gitlab.com/fdroid/fdroiddata;
test -d build || mkdir build;
for f in `git diff --name-only FETCH_HEAD`; do
appid=`echo $f | sed -n -e 's,^metadata/\(.*\)\.txt,\1,p'
-e 's,^metadata/\(.*\)\.yml,\1,p'`;
export CHANGED="$CHANGED $appid";
grep -q "^Repo *Type\W *git" $f && git -C build clone `sed -n "s,^Repo *:,,p" $f` $appid;
done;
fi
- export EXITVALUE=0
- fdroid lint -f || {
- fdroid lint -f $CHANGED || {
export EXITVALUE=1;
printf "\nThese files have lint issues:\n";
fdroid rewritemeta -l;
fdroid rewritemeta -l $CHANGED;
printf "\nThese are the formatting issues:\n";
fdroid rewritemeta;
fdroid rewritemeta $CHANGED;
git --no-pager diff --color=always;
}
- exit $EXITVALUE