Skip to content

Commit 64a3738

Browse files
committed
update release scripts
1 parent 1659a9b commit 64a3738

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

release.ps1

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,19 @@ try {
7070
exit 1
7171
}
7272

73-
# Check if there are uncommitted changes
74-
$UncommittedChanges = $false
75-
try {
76-
$null = git diff-index --quiet HEAD -- 2>&1
77-
} catch {
78-
$UncommittedChanges = $true
79-
}
80-
81-
if ($UncommittedChanges) {
82-
Write-Warning "You have uncommitted changes"
83-
$Response = Read-Host "Do you want to continue anyway? (y/N)"
84-
if ($Response -notmatch '^[Yy]$') {
85-
Write-Info "Release cancelled"
86-
exit 0
73+
# Check if there are uncommitted changes (only tracked files, ignore untracked)
74+
# Use git status --porcelain to check for actual changes
75+
$StatusOutput = git status --porcelain 2>&1
76+
if ($StatusOutput) {
77+
# Filter out untracked files (lines starting with ??)
78+
$TrackedChanges = $StatusOutput | Where-Object { $_ -notmatch '^\?\?' }
79+
if ($TrackedChanges) {
80+
Write-Warning "You have uncommitted changes in tracked files"
81+
$Response = Read-Host "Do you want to continue anyway? (y/N)"
82+
if ($Response -notmatch '^[Yy]$') {
83+
Write-Info "Release cancelled"
84+
exit 0
85+
}
8786
}
8887
}
8988

release.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,19 @@ if ! git rev-parse --git-dir > /dev/null 2>&1; then
8181
exit 1
8282
fi
8383

84-
# Check if there are uncommitted changes
85-
if ! git diff-index --quiet HEAD --; then
86-
print_warning "You have uncommitted changes"
87-
read -p "Do you want to continue anyway? (y/N) " -n 1 -r
88-
echo
89-
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
90-
print_info "Release cancelled"
91-
exit 0
84+
# Check if there are uncommitted changes (only tracked files, ignore untracked)
85+
# Use git status --porcelain to check for actual changes (returns empty if clean)
86+
if [ -n "$(git status --porcelain 2>/dev/null)" ]; then
87+
# Filter out untracked files (lines starting with ??)
88+
TRACKED_CHANGES=$(git status --porcelain 2>/dev/null | grep -v '^??' || true)
89+
if [ -n "$TRACKED_CHANGES" ]; then
90+
print_warning "You have uncommitted changes in tracked files"
91+
read -p "Do you want to continue anyway? (y/N) " -n 1 -r
92+
echo
93+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
94+
print_info "Release cancelled"
95+
exit 0
96+
fi
9297
fi
9398
fi
9499

0 commit comments

Comments
 (0)