diff --git a/.githooks/pre-push.ps1 b/.githooks/pre-push.ps1 index 3ad8c65de76..e23817b3420 100644 --- a/.githooks/pre-push.ps1 +++ b/.githooks/pre-push.ps1 @@ -32,12 +32,12 @@ if ($LASTEXITCODE -ne 0) { } # Check if current branch needs rebasing -Write-Host "Checking if branch needs rebasing..." -ForegroundColor Green $mergeBase = git merge-base HEAD upstream/dev $upstreamHead = git rev-parse upstream/dev if ($mergeBase -ne $upstreamHead) { $response = Read-Host "Your branch is not up to date with upstream/dev. Do you want to rebase? (Y/N)" if ($response -eq 'Y' -or $response -eq 'y') { + Write-Host "Rebasing branch to upstream/dev..." -ForegroundColor Green git rebase upstream/dev if ($LASTEXITCODE -ne 0) { Write-Host "Error: Rebase failed. Please resolve conflicts manually." -ForegroundColor Red @@ -45,6 +45,8 @@ if ($mergeBase -ne $upstreamHead) { } Write-Host "Running azdev setup -c $AZURE_CLI_FOLDER " -ForegroundColor Green azdev setup -c $AZURE_CLI_FOLDER + Write-Host "Rebase completed. Please push with 'git push --force' again." -ForegroundColor Green + exit 1 } else { Write-Host "Continuing without rebase..." -ForegroundColor Yellow } diff --git a/.githooks/pre-push.sh b/.githooks/pre-push.sh index 2cbf35fa4f5..cbd7ab3e9fa 100644 --- a/.githooks/pre-push.sh +++ b/.githooks/pre-push.sh @@ -29,23 +29,18 @@ if [ $? -ne 0 ]; then fi # Check if current branch needs rebasing -echo "\033[0;32mChecking if branch needs rebasing...\033[0m" MERGE_BASE=$(git merge-base HEAD upstream/dev) UPSTREAM_HEAD=$(git rev-parse upstream/dev) if [ "$MERGE_BASE" != "$UPSTREAM_HEAD" ]; then - read -p "Your branch is not up to date with upstream/dev. Do you want to rebase? (Y/N) " response - if [[ "$response" =~ ^[Yy]$ ]]; then - git rebase upstream/dev - if [ $? -ne 0 ]; then - echo "\033[0;31mError: Rebase failed. Please resolve conflicts manually.\033[0m" - exit 1 - fi - echo "\033[0;32mRunning azdev setup -c $AZURE_CLI_FOLDER\033[0m" - azdev setup -c "$AZURE_CLI_FOLDER" - else - echo "\033[0;33mContinuing without rebase...\033[0m" + echo "\033[0;32mRebasing branch to upstream/dev...\033[0m" + git rebase upstream/dev + if [ $? -ne 0 ]; then + echo "\033[0;31mError: Rebase failed. Please resolve conflicts manually.\033[0m" + exit 1 fi + echo "\033[0;32mRunning azdev setup -c $AZURE_CLI_FOLDER\033[0m" + azdev setup -c "$AZURE_CLI_FOLDER" fi # get the current branch name