punktdateien/bin/updatechecker

33 lines
1.3 KiB
Text
Raw Normal View History

2023-12-13 19:32:24 +01:00
#!/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"
2023-12-13 20:10:04 +01:00
export "COMMIT=$(env PAGER= git log -n 1 --pretty=format:\"%H\")"
2023-12-13 19:32:24 +01:00
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')"
2023-12-13 20:10:04 +01:00
if [ "$COMMIT" == "$LATEST_COMMIT" ] || [ -n "$COMMIT" ]; then
2023-12-13 20:03:46 +01:00
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 " -> Message: ${LATEST_COMMIT_MESSAGE}"
echo ""
echo -e "${COLOR_BOLD}Update by executing \"dotfiles-updater\""
2023-12-13 20:03:46 +01:00
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
2023-12-13 19:32:24 +01:00
fi