eolas/scripts/auto_save.sh

33 lines
790 B
Bash
Raw Normal View History

2022-12-07 07:30:05 +00:00
#!/bin/bash
# Automatically commits/pull changes to the remote ZK repository.
2022-12-07 07:30:05 +00:00
tidy_filenames="${EOLAS_DIR}/scripts/tidy_filenames.sh"
purge_images="${EOLAS_DIR}/scripts/purge_images.sh"
2023-01-21 12:18:17 +00:00
2024-02-25 19:38:14 +00:00
cd $EOLAS_DIR
2022-12-07 07:30:05 +00:00
echo "Standardising file-names..."
2024-02-25 19:38:14 +00:00
source ${tidy_filenames}
echo "Removing unused images..."
2024-02-25 19:38:14 +00:00
source ${purge_images}
2023-01-21 13:06:01 +00:00
echo "Checking for changes..."
2023-01-21 13:50:33 +00:00
git pull >/dev/null 2>&1
2023-01-21 13:07:01 +00:00
2023-02-21 07:39:26 +00:00
changes_exist="$(git status --porcelain | wc -l)"
2022-12-07 07:30:05 +00:00
# If no changes, exit. Else commit and push with timestamp
2023-02-21 07:39:26 +00:00
if [ "$changes_exist" -eq 0 ]; then
echo "No changes, exiting"
2022-12-07 07:30:05 +00:00
exit 0
fi
2024-02-26 19:10:38 +00:00
echo "Changes exist. Updating remote..."
2023-01-21 13:50:33 +00:00
git pull >/dev/null 2>&1
2022-12-07 07:30:05 +00:00
git add .
2022-12-09 08:30:05 +00:00
git commit -q -m "Autosave: $(date +"%Y-%m-%d %H:%M:%S")"
2023-01-21 13:51:23 +00:00
git push
notify-send "Auto-save complete" "Changes committed to remote repository"