9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-21 15:59:28 +00:00
Files
Gale/scripts/upstreamCommit.sh
Dreeam d95dc9d8a0 Updated Upstream (Paper)
Upstream has released updates that appear to apply and compile correctly

Paper Changes:
PaperMC/Paper@2df5bba Log throwable when failing to save chunk/poi/entity data
PaperMC/Paper@44c3dd0 fix exact choice shapeless recipes (#10973)
2024-07-18 06:44:23 +08:00

57 lines
1.4 KiB
Bash

#!/usr/bin/env bash
# requires curl & jq
# Credit: https://github.com/PurpurMC/Purpur
# upstreamCommit --paper HASH
# flag: --paper HASH - (Optional) the commit hash to use for comparing commits between paper (PaperMC/Paper/compare/HASH...HEAD)
function getCommits() {
curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/"$1"/compare/"$2"..."$3" | jq -r '.commits[] | "'"$1"'@\(.sha[:7]) \(.commit.message | split("\r\n")[0] | split("\n")[0])"'
}
(
set -e
PS1="$"
paperHash=$(git diff gradle.properties | awk '/^-paperRef =/{print $NF}')
TEMP=$(getopt --long paper: -o "" -- "$@")
eval set -- "$TEMP"
while true; do
case "$1" in
--paper)
paperHash="$2"
shift 2
;;
*)
break
;;
esac
done
paper=""
updated=""
logsuffix=""
# Paper updates
if [ -n "$paperHash" ]; then
newHash=$(git diff gradle.properties | awk '/^+paperRef =/{print $NF}')
paper=$(getCommits "PaperMC/Paper" "$paperHash" $(echo $newHash | grep . -q && echo $newHash || echo "HEAD"))
# Updates found
if [ -n "$paper" ]; then
updated="Paper"
logsuffix="$logsuffix\n\nPaper Changes:\n$paper"
fi
fi
disclaimer="Upstream has released updates that appear to apply and compile correctly"
log="Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}"
git add gradle.properties
echo -e "$log" | git commit -F -
) || exit 1