Skip to content

Commit e6251b4

Browse files
Rutvik SaptarshiRutvik Saptarshi
authored andcommitted
added fetch logic
1 parent 61eb572 commit e6251b4

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

build-aux/build-debs.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ if [ -f "$ROOT/Makefile" ]; then
2626
fi
2727
rm -rf "$ROOT/dist"
2828

29+
# ... [Previous setup and make distclean] ...
30+
2931
UBUNTU_VERSION=$1
3032
CURRENT_BRANCH=$(git -C "$ROOT" rev-parse --abbrev-ref HEAD)
3133

@@ -34,16 +36,19 @@ if [ "$UBUNTU_VERSION" = "u24" ]; then
3436
OVS_BASE="3.3.6"
3537
OVN_BASE="24.03.6"
3638

37-
# Case 1: Already on a u24 branch
39+
# Case 1: Already on a u24 branch - No Switch/Fetch needed
3840
if echo "$CURRENT_BRANCH" | grep -q "u24"; then
3941
echo "Current branch '$CURRENT_BRANCH' is already a u24 branch. Keeping it."
4042

4143
# Case 2: On a u22 branch, try to swap 'u22' for 'u24'
4244
elif echo "$CURRENT_BRANCH" | grep -q "u22"; then
43-
# String substitution: replace 'u22' with 'u24'
4445
TARGET_BRANCH="${CURRENT_BRANCH/u22/u24}"
45-
echo "Current branch '$CURRENT_BRANCH' contains 'u22'. Attempting switch to '$TARGET_BRANCH'."
46+
echo "Current branch '$CURRENT_BRANCH' contains 'u22'. Fetching..."
4647

48+
# Fetch before switching
49+
git -C "$ROOT" fetch
50+
51+
echo "Attempting switch to '$TARGET_BRANCH'..."
4752
if git -C "$ROOT" checkout "$TARGET_BRANCH"; then
4853
echo "Successfully switched to specific branch '$TARGET_BRANCH'."
4954
else
@@ -53,7 +58,8 @@ if [ "$UBUNTU_VERSION" = "u24" ]; then
5358

5459
# Case 3: Generic branch (no u22/u24 in name) -> Default to main-u24
5560
else
56-
echo "Current branch '$CURRENT_BRANCH' does not match u24 patterns. Defaulting to 'main-u24'."
61+
echo "Current branch '$CURRENT_BRANCH' does not match u24 patterns. Fetching and defaulting to 'main-u24'."
62+
git -C "$ROOT" fetch
5763
git -C "$ROOT" checkout "main-u24"
5864
fi
5965

@@ -64,10 +70,13 @@ elif [ "$UBUNTU_VERSION" = "u22" ] || [ -z "$UBUNTU_VERSION" ]; then
6470

6571
# Case 1: On a u24 branch, try to swap 'u24' for 'u22'
6672
if echo "$CURRENT_BRANCH" | grep -q "u24"; then
67-
# String substitution: replace 'u24' with 'u22'
6873
TARGET_BRANCH="${CURRENT_BRANCH/u24/u22}"
69-
echo "Current branch '$CURRENT_BRANCH' contains 'u24'. Attempting switch to '$TARGET_BRANCH'."
74+
echo "Current branch '$CURRENT_BRANCH' contains 'u24'. Fetching..."
7075

76+
# Fetch before switching
77+
git -C "$ROOT" fetch
78+
79+
echo "Attempting switch to '$TARGET_BRANCH'..."
7180
if git -C "$ROOT" checkout "$TARGET_BRANCH"; then
7281
echo "Successfully switched to specific branch '$TARGET_BRANCH'."
7382
else
@@ -76,7 +85,6 @@ elif [ "$UBUNTU_VERSION" = "u22" ] || [ -z "$UBUNTU_VERSION" ]; then
7685
fi
7786

7887
# Case 2: Already on u22 or generic branch -> Keep it.
79-
# (We assume generic branches are intended for the default/u22 build)
8088
else
8189
echo "Current branch '$CURRENT_BRANCH' is appropriate for u22. Keeping it."
8290
fi
@@ -86,6 +94,8 @@ else
8694
exit 1
8795
fi
8896

97+
# ... [Submodule update and build logic below] ...
98+
8999
# 2. Initialize and update submodules recursively
90100
# Performed after branch switching to ensure correct submodules are pulled
91101
git -C "$ROOT" submodule update --init --recursive

0 commit comments

Comments
 (0)