captaincore/app/quicksave/show-changes
2024-05-04 22:09:09 -04:00

53 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# Shows file changes between Quicksaves.
#
# `captaincore quicksave show-changes <site> <commit-hash> [<match>]`
#
if [ ${#@} -lt 2 ]; then
echo -e "${COLOR_RED}Error:${COLOR_NORMAL} Please specify a <site> and <commit-hash>."
exit
fi
while read config; do
if [[ "$config" == "Error:"* ]]; then
continue
fi
declare "$config"
done <<< "$(php ${CAPTAINCORE_PATH}/lib/local-scripts/configs.php fetch)"
site=$1
commit=$2
match=$3
run_command() {
# Extract environment
if [[ "$site" == *"-staging"* ]]; then
environment=staging
else
environment=production
fi
IFS=$'\n'$'\r'; for line in $(captaincore site get $site --bash --captain-id=$CAPTAIN_ID); do declare "$line"; done
# Return error if domain not found
if [[ "$domain" == "" ]] || [[ "$site" == "" ]]; then
echo "Can't locate website for site $site"
return
fi
if [ ! -d "$path/${site}_${site_id}/${environment}/quicksave/" ]; then
echo -e "Error: Unable to locate Quicksave."
return
fi
cd $path/${site}_${site_id}/${environment}/quicksave/
git_show=$( git show $commit --name-status --format= $match )
echo "$git_show"
}
run_command