punktdateien/bin/updatechecker
2023-12-13 20:25:31 +01:00

32 lines
1.3 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 "COMMIT=$(env PAGER= git log -n 1 --pretty=format:\"%H\")"
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 [ "$COMMIT" == "$LATEST_COMMIT" ] || [ -z "$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 punktdateien is available."
echo -e "${COLOR_REGULAR}Latest commit: ${LATEST_COMMIT}"
echo " -> Message: ${LATEST_COMMIT_MESSAGE}"
echo ""
echo -e "${COLOR_BOLD}Update by executing \"dotfiles-updater\""
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