Skip to content

Commit 8245272

Browse files
committed
feat(scripts): auto-detect pilota branch from Cargo.toml in volo-cli-test
1 parent ec08b79 commit 8245272

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

scripts/volo-cli-test.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,32 @@ init() {
3737
export VOLO_DIR="$PWD"
3838
echo_command cargo build -p volo-cli
3939
export VOLO_CLI="$PWD/target/debug/volo"
40+
detect_pilota_branch
41+
}
42+
43+
detect_pilota_branch() {
44+
local cargo_toml="$VOLO_DIR/Cargo.toml"
45+
46+
if grep -q '^\[patch\.crates-io\]' "$cargo_toml"; then
47+
local pilota_line=$(sed -n '/^\[patch\.crates-io\]/,/^\[/p' "$cargo_toml" | grep '^pilota[[:space:]]*=' | grep 'branch[[:space:]]*=' | head -n 1)
48+
49+
if [ -n "$pilota_line" ]; then
50+
export PILOTA_BRANCH=$(echo "$pilota_line" | sed -n 's/.*branch[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p')
51+
echo "Detected pilota patch: branch = $PILOTA_BRANCH"
52+
return
53+
fi
54+
fi
55+
56+
export PILOTA_BRANCH="main"
57+
echo "No pilota patch detected, using default: branch = main"
4058
}
4159

4260
append_volo_dep_item() {
4361
echo "$1 = { path = \"$VOLO_DIR/$1\" }" >> Cargo.toml
4462
}
4563

4664
append_pilota_dep_item() {
47-
echo "$1 = { git = \"https://github.com/cloudwego/pilota.git\", branch = \"main\" }" >> Cargo.toml
65+
echo "$1 = { git = \"https://github.com/cloudwego/pilota.git\", branch = \"$PILOTA_BRANCH\" }" >> Cargo.toml
4866
}
4967

5068
patch_cargo_toml() {

0 commit comments

Comments
 (0)