Skip to content

Commit 9d28eec

Browse files
committed
fix: improve update_core_version function and add input validation
- Fix update_core_version to only update package version, not dependencies - Add input validation for vtcode-core version to ensure valid semver format - Prevent accidental corruption of dependency versions - Reset corrupted vtcode-core/Cargo.toml file
1 parent bdca6d9 commit 9d28eec

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

scripts/release.sh

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,17 @@ update_version() {
168168
update_core_version() {
169169
local new_version=$1
170170

171-
# Update vtcode-core Cargo.toml only
172-
sed -i.bak "s/^version = \".*\"/version = \"$new_version\"/" vtcode-core/Cargo.toml
173-
rm vtcode-core/Cargo.toml.bak
174-
175-
print_success "Updated vtcode-core version to $new_version"
171+
# Update only the package version line in vtcode-core/Cargo.toml
172+
# Find the line number of the package version and update only that line
173+
local line_num=$(grep -n "^version = " vtcode-core/Cargo.toml | head -1 | cut -d: -f1)
174+
if [ -n "$line_num" ]; then
175+
sed -i.bak "${line_num}s/version = \".*\"/version = \"$new_version\"/" vtcode-core/Cargo.toml
176+
rm vtcode-core/Cargo.toml.bak
177+
print_success "Updated vtcode-core version to $new_version"
178+
else
179+
print_error "Could not find version line in vtcode-core/Cargo.toml"
180+
return 1
181+
fi
176182
}
177183

178184
# Function to validate package metadata
@@ -506,14 +512,22 @@ main() {
506512
core_version="$version"
507513
print_info "vtcode-core will be bumped to $core_version (dry-run)"
508514
else
509-
# Interactive mode - prompt for core version
510-
echo
511-
read -p "Enter new vtcode-core version (leave blank to skip): " core_version
512-
if [ -n "$core_version" ]; then
513-
print_info "vtcode-core will be bumped to $core_version"
514-
else
515-
print_warning "Skipping vtcode-core version bump"
516-
fi
515+
# Interactive mode - prompt for core version with validation
516+
while true; do
517+
echo
518+
read -p "Enter new vtcode-core version (leave blank to skip): " core_version_input
519+
if [ -z "$core_version_input" ]; then
520+
print_warning "Skipping vtcode-core version bump"
521+
core_version=""
522+
break
523+
elif [[ "$core_version_input" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.-]+)?$ ]]; then
524+
core_version="$core_version_input"
525+
print_info "vtcode-core will be bumped to $core_version"
526+
break
527+
else
528+
print_error "Invalid version format. Please use semantic versioning (e.g., 1.2.3, 1.2.3-alpha.1)"
529+
fi
530+
done
517531
fi
518532

519533
# Confirm release

0 commit comments

Comments
 (0)