-
Notifications
You must be signed in to change notification settings - Fork 1
/
merge-squash.cmd
42 lines (38 loc) · 976 Bytes
/
merge-squash.cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
@echo off
setlocal enabledelayedexpansion
cls
SET SCRIPT_PATH=%~dps0
cd /d "%SCRIPT_PATH%"
REM
REM Script Consts.
SET GITPATH=%ProgramFiles%\Git\cmd
SET GIT_BIN="%GITPATH%\git.exe"
REM
echo [INFO] Checking prerequisites ...
SET GIT_BIN=
FOR /F "tokens=*" %%A IN ('where git 2^> NUL:') DO SET GIT_BIN="%%A"
IF NOT EXIST %GIT_BIN% echo [ERROR] GIT_BIN not found. & goto :pauseExit
REM
REM Script parameters.
SET BRANCH_TO_MERGE=%1
IF NOT DEFINED BRANCH_TO_MERGE SET BRANCH_TO_MERGE=work
REM
call :runGit merge --squash --no-commit "%BRANCH_TO_MERGE%"
REM call :runGit commit -m "Merged branch \"%BRANCH_TO_MERGE%\""
REM
goto :eof
REM ====================
REM FUNCTION BLOCK START
REM ====================
:runGit
echo [INFO] git %*
%GIT_BIN% %*
SET RESULT=%ERRORLEVEL%
IF NOT "%RESULT%" == "0" echo [ERROR] git FAILED with error code #%RESULT%. & goto :pauseExit
goto :eof
:pauseExit
pause
goto :eof
REM ==================
REM FUNCTION BLOCK END
REM ==================