punktdateien/bin/updatechecker
2023-12-13 20:03:46 +01:00

29 lines
1.1 KiB
Bash
Executable file

#!/bin/bash
cd "$HOME/.dotfiles"
export "COLOR=31"
export "COLOR_REGULAR=\e[0;${COLOR}m"
export "COLOR_BOLD=\e[1;${COLOR}m"
export "COLOR_RESET=\e[0m"
export "LATEST_COMMIT=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.id')"
export "LATEST_COMMIT_MESSAGE=$(curl -sX 'GET' 'https://git.staropensource.de/api/v1/repos/JeremyStarTM/punktdateien/branches/develop' -H 'accept: application/json'|jq --monochrome-output '.commit.message'|sed 's/\\n//g')"
if [ "$(env PAGER= git log -n 1 --pretty=format:\"%H\")" == "$LATEST_COMMIT" ]; then
export "UPDATE=false"
else
export "UPDATE=true"
fi
if [ ! "$SCRIPTED" == "true" ]; then
if [ "$UPDATE" == "true" ]; then
echo -e "${COLOR_BOLD}An update for jstm's punkdateien is available."
echo -e "${COLOR_REGULAR}Latest commit: ${LATEST_COMMIT}"
echo -e "${COLOR_REGULAR} -> Message: ${LATEST_COMMIT_MESSAGE}"
echo -en "${COLOR_RESET}"
elif [ ! "${BASHRC}" == "true" ]; then
echo -e "${COLOR_BOLD}No update available"
fi
else
if [ "$UPDATE" == "true" ]; then
echo "$LATEST_COMMIT_MESSAGE"
fi
fi