1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:17:36 +00:00

Ports: Unify the git "origin" and the working copy

I've lost more changes to "you forgot to push the changed commits to the
remote" than I'd like to admit, so let's just unify both and only ever
use the actual working repository for detemining whether any patches
have changed.
This commit is contained in:
Tim Schumacher 2022-09-16 23:43:16 +02:00 committed by Ali Mohammad Pur
parent cb2f0d9861
commit 1b9fb7041d

View file

@ -95,13 +95,10 @@ cleanup_git() {
run git clean -xffd >/dev/null 2>&1 run git clean -xffd >/dev/null 2>&1
} }
# Use the local git target repo as the workdir # Make sure to clean up the git repository of the port afterwards.
# Make sure to clean it up afterwards
if [ -n "${IN_SERENITY_PORT_DEV:-}" ]; then if [ -n "${IN_SERENITY_PORT_DEV:-}" ]; then
echo "WARNING: All changes to the workdir in the current state (inside ./package.sh dev) are temporary!" echo "WARNING: All changes to the workdir in the current state (inside ./package.sh dev) are temporary!"
echo " They will be reverted once the command exits!" echo " They will be reverted once the command exits!"
nongit_workdir="$workdir"
workdir=".$workdir-git"
trap "run cleanup_git" EXIT trap "run cleanup_git" EXIT
fi fi
@ -713,18 +710,16 @@ do_dev() {
exit 1 exit 1
fi fi
git_repo=".${workdir////_}-git" [ -d "$workdir" ] || (
[ -d "$git_repo" ] || ( do_fetch
mv "$workdir" "$git_repo" pushd "$workdir"
pushd "$git_repo" if [ ! -d ".git" ]; then
if [ ! -d "$git_repo/.git" ]; then
git init . git init .
git config core.autocrlf false git config core.autocrlf false
git add --all --force git add --all --force
git commit -a -m 'Initial import' git commit -a -m 'Initial import'
fi fi
# Make it allow pushes from other local checkouts
git config receive.denyCurrentBranch ignore
# Import patches as commits, or ask the user to commit them # Import patches as commits, or ask the user to commit them
# if they're not git patches already. # if they're not git patches already.
if [ -d "${PORT_META_DIR}/patches" ] && [ -n "$(find -L "${PORT_META_DIR}/patches" -maxdepth 1 -name '*.patch' -print -quit)" ]; then if [ -d "${PORT_META_DIR}/patches" ] && [ -n "$(find -L "${PORT_META_DIR}/patches" -maxdepth 1 -name '*.patch' -print -quit)" ]; then
@ -800,33 +795,25 @@ do_dev() {
popd popd
) )
[ -d "$git_repo" ] && [ ! -d "$workdir" ] && {
git clone --config core.autocrlf=false "$git_repo" "$workdir"
}
[ -d "$workdir/.git" ] || { [ -d "$workdir/.git" ] || {
>&2 echo "$workdir does not appear to be a git repository, if you did this manually, you're on your own" >&2 echo "$workdir does not appear to be a git repository."
if prompt_yes_no "Otherwise, press 'y' to remove that directory and clone it again"; then >&2 echo "If you want to use './package.sh dev', please run './package.sh clean' first."
rm -fr "$workdir" exit 1
git clone --config core.autocrlf=false "$git_repo" "$workdir"
else
exit 1
fi
} }
local first_hash="$(git -C "$git_repo" rev-list --max-parents=0 HEAD)" local first_hash="$(git -C "$workdir" rev-list --max-parents=0 HEAD)"
pushd "$workdir" pushd "$workdir"
launch_user_shell launch_user_shell
popd >/dev/null 2>&1 popd >/dev/null 2>&1
local current_hash="$(git -C "$git_repo" rev-parse HEAD)" local current_hash="$(git -C "$workdir" rev-parse HEAD)"
# If the hashes are the same, we have no patches, otherwise generate patches # If the hashes are the same, we have no patches, otherwise generate patches
if [ "$first_hash" != "$current_hash" ]; then if [ "$first_hash" != "$current_hash" ]; then
>&2 echo "Note: Regenerating patches as there are some commits in the port repo (started at $first_hash, now is $current_hash)" >&2 echo "Note: Regenerating patches as there are some commits in the port repo (started at $first_hash, now is $current_hash)"
rm -fr "${PORT_META_DIR}"/patches/*.patch rm -fr "${PORT_META_DIR}"/patches/*.patch
git -C "$git_repo" format-patch --no-numbered --zero-commit --no-signature --full-index "$first_hash" -o "$(realpath "${PORT_META_DIR}/patches")" git -C "$workdir" format-patch --no-numbered --zero-commit --no-signature --full-index "$first_hash" -o "$(realpath "${PORT_META_DIR}/patches")"
do_generate_patch_readme do_generate_patch_readme
fi fi
} }
@ -865,7 +852,6 @@ parse_arguments() {
do_clean do_clean
fi fi
fi fi
do_fetch
do_dev do_dev
;; ;;
*) *)