Commit 4d401a6b authored by Peter Nerlich's avatar Peter Nerlich
Browse files

Pipeline for reporting upstream changes automatically

parent 8bc4273c
image: alpine
before_script:
- apk add git
- TARGET=$(git rev-parse HEAD)
- ./update.sh
- git checkout $TARGET
report:
stage: test
only:
- master
script:
- ./show-upstream-changes.sh -nc 2>&1 | tee upstream-report-color.txt
- ./show-upstream-changes.sh -n > upstream-report.txt
artifacts:
paths:
- upstream-report.txt
- upstream-report-color.txt
expire_in: 1 year
cache:
key: report
paths:
- ./*/.git
#!/bin/sh
function help {
echo -e "$0"
echo -e "\t\t-h\t\thelp message"
echo -e "\t\t-n\t\tno pager"
echo -e "\t\t-c\t\tforce color"
}
# list of arguments expected in the input
optstring=":hnc"
while getopts ${optstring} arg; do
case ${arg} in
h)
help
;;
n)
NOPAGER=1
;;
c)
FORCECOLOR=1
;;
:)
echo "$0: Must supply an argument to -$OPTARG." >&2
exit 1
;;
?)
echo "Invalid option: -${OPTARG}."
exit 2
;;
esac
done
[ "x$FORCECOLOR" == "x" ] && [ "$NOPAGER" == "1" ] || COLOR="--color=always" COLORHINT="\nIf this shows incorrectly, try opening with \`less -R\` (or use the non-colored version).\n"
OUT="REMEMBER TO FETCH UPSTREAM CHANGES FIRST!\n\
WE CANNOT LIST WHAT WE DON'T KNOW ABOUT!\n\
${COLORHINT}\
\n#########################################\n\n\n\
\
$(git submodule foreach ' \
......@@ -13,7 +49,7 @@ $(git submodule foreach ' \
echo -e "\n################################################\n$(git remote get-url origin)\n################################################\n" \
&& \
# show all new commits, including the last that we have (where our HEAD points) \
git --no-pager log --color=always --decorate=short $sha1~..origin/master --graph \
git --no-pager log '$COLOR' --decorate=short $sha1~..origin/master --graph \
\
|| \
# no commits? cool! print that! \
......@@ -24,4 +60,4 @@ $(git submodule foreach ' \
echo -e "\n" \
')"
[ "$1" == "--no-pager" ] && echo "$OUT" || echo "$OUT" | less -R
[ "$NOPAGER" == "1" ] && echo -e "$OUT" || echo -e "$OUT" | less -R
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment