fix "fatal: couldn't find remote ref master"
This commit is contained in:
parent
101aa9c2e0
commit
05695a01eb
1 changed files with 20 additions and 1 deletions
21
builder.sh
21
builder.sh
|
@ -47,7 +47,26 @@ update_patches() {
|
||||||
echo "Patches directory already exists. Cleaning and pulling updates..."
|
echo "Patches directory already exists. Cleaning and pulling updates..."
|
||||||
cd "$PATCHES_DIR" || { echo "Failed to navigate to patches directory. Exiting."; exit 1; }
|
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 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
|
else
|
||||||
echo "Patches directory does not exist. Cloning repository..."
|
echo "Patches directory does not exist. Cloning repository..."
|
||||||
git clone "$PATCHES_REPO" "$PATCHES_DIR" || { echo "Failed to clone patches repository. Exiting."; exit 1; }
|
git clone "$PATCHES_REPO" "$PATCHES_DIR" || { echo "Failed to clone patches repository. Exiting."; exit 1; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue