fix "fatal: couldn't find remote ref master"

This commit is contained in:
partisan 2024-07-20 11:30:23 +02:00
parent 1778336ea1
commit 8d3571dd99

View file

@ -47,7 +47,26 @@ update_patches() {
echo "Patches directory already exists. Cleaning and pulling updates..."
cd "$PATCHES_DIR" || { echo "Failed to navigate to patches directory. Exiting."; exit 1; }
git clean -xdf || { echo "Failed to clean patches directory. Exiting."; exit 1; }
git pull origin master || { echo "Failed to pull updates from patches repository. Exiting."; exit 1; }
# Stash any local changes to ensure a clean rebase
git stash push --include-untracked || { echo "Failed to stash local changes. Exiting."; exit 1; }
# Fetching all branches
git fetch || { echo "Failed to fetch updates from patches repository. Exiting."; exit 1; }
# Trying to rebase onto 'main' branch
if git show-ref --verify --quiet refs/heads/main; then
git rebase origin/main || { echo "Failed to rebase updates from main branch. Exiting."; exit 1; }
elif git show-ref --verify --quiet refs/heads/master; then
# Fallback to 'master' branch if 'main' does not exist
git rebase origin/master || { echo "Failed to rebase updates from master branch. Exiting."; exit 1; }
else
echo "No valid branch (main or master) found in patches repository. Exiting."
exit 1
fi
# Drop stashed changes to discard local modifications
git stash drop || { echo "Failed to drop stashed changes. Exiting."; exit 1; }
else
echo "Patches directory does not exist. Cloning repository..."
git clone "$PATCHES_REPO" "$PATCHES_DIR" || { echo "Failed to clone patches repository. Exiting."; exit 1; }