Skip to content

Commit 455f2f5

Browse files
committed
Add unpushed commits check and improve push logic in release script
1 parent 888ded7 commit 455f2f5

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

scripts/trigger-release.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,15 @@ if [ "$DRY_RUN" = true ]; then
151151
echo "---"
152152
echo ""
153153

154+
# Check for unpushed commits in dry-run
155+
git fetch origin
156+
LOCAL_COMMITS=$(git log origin/main..HEAD --oneline 2>/dev/null || git log origin/master..HEAD --oneline 2>/dev/null || echo "")
157+
if [ -n "$LOCAL_COMMITS" ]; then
158+
echo "Local commits that would be pushed:"
159+
echo "$LOCAL_COMMITS"
160+
echo ""
161+
fi
162+
154163
echo "🚫 DRY RUN: No tag created, nothing pushed"
155164
else
156165
# Check if tag already exists
@@ -159,6 +168,31 @@ else
159168
exit 1
160169
fi
161170

171+
# Fetch to check for unpushed commits
172+
echo "Checking for unpushed commits..."
173+
git fetch origin
174+
175+
# Determine the main branch name
176+
MAIN_BRANCH="main"
177+
if ! git show-ref --verify --quiet refs/remotes/origin/main; then
178+
MAIN_BRANCH="master"
179+
fi
180+
181+
# Check if there are local commits to push
182+
LOCAL_COMMITS=$(git log origin/$MAIN_BRANCH..HEAD --oneline 2>/dev/null || echo "")
183+
if [ -n "$LOCAL_COMMITS" ]; then
184+
echo "Pushing local commits first..."
185+
echo "Commits to push:"
186+
echo "$LOCAL_COMMITS"
187+
echo ""
188+
git push origin HEAD:$MAIN_BRANCH
189+
echo "✓ Local commits pushed"
190+
echo ""
191+
else
192+
echo "No local commits to push"
193+
echo ""
194+
fi
195+
162196
# Create tag with message
163197
echo "Creating tag $TAG_NAME..."
164198
if [ -z "$CHANGES" ]; then

0 commit comments

Comments
 (0)