67 lines
1.8 KiB
Batchfile
67 lines
1.8 KiB
Batchfile
@echo off
|
|
setlocal ENABLEDELAYEDEXPANSION
|
|
|
|
:: Ensure we're inside a Git repository
|
|
git rev-parse --git-dir > NUL 2>&1
|
|
if ERRORLEVEL 1 (
|
|
echo Error: This directory is not a Git repository.
|
|
exit /b 1
|
|
)
|
|
|
|
:: Get the current branch name
|
|
FOR /F "delims=" %%i IN ('git symbolic-ref --short HEAD') DO SET CURRENT_BRANCH=%%i
|
|
|
|
:: Check if the current branch is 'development'
|
|
if NOT "!CURRENT_BRANCH!"=="development" (
|
|
echo Error: You are not on the 'development' branch.
|
|
echo Please switch to the 'development' branch and run this script again.
|
|
exit /b 1
|
|
)
|
|
|
|
:: Prompt for a commit message
|
|
set /p COMMIT_MESSAGE=Enter your commit message:
|
|
|
|
if "%COMMIT_MESSAGE%"=="" (
|
|
echo Error: Commit message cannot be empty.
|
|
exit /b 1
|
|
)
|
|
|
|
:: Add all changes
|
|
git add --all
|
|
|
|
:: Commit the changes with the provided message
|
|
git commit -m "%COMMIT_MESSAGE%"
|
|
|
|
:: Show the last commit
|
|
echo Last commit on 'development' branch:
|
|
git --no-pager log -1 --pretty=format:"%%h - %%s (%%an, %%ar)"
|
|
echo.
|
|
|
|
:: Prompt for confirmation to push to 'production'
|
|
set /p CONFIRMATION=Do you want to merge 'development' into 'production' and push to the remote repository? (yes/no):
|
|
|
|
if /I NOT "%CONFIRMATION%"=="yes" (
|
|
echo Aborting push to 'production' branch.
|
|
exit /b 0
|
|
)
|
|
|
|
:: Fetch the latest changes from the remote repository
|
|
git fetch origin
|
|
|
|
:: Switch to the 'production' branch
|
|
git checkout production
|
|
|
|
:: Pull the latest changes in 'production' branch
|
|
git pull origin production
|
|
|
|
:: Merge 'development' into 'production'
|
|
git merge --no-ff development -m "Merge branch 'development' into 'production'"
|
|
|
|
:: Push the 'production' branch to the remote repository
|
|
git push origin production
|
|
|
|
:: Switch back to the 'development' branch
|
|
git checkout development
|
|
|
|
echo Successfully pushed changes from 'development' to 'production' branch.
|