Skip to content

Commit

Permalink
feat(branch): Add pull switch
Browse files Browse the repository at this point in the history
  • Loading branch information
Jandini authored Dec 1, 2020
1 parent 6d8e002 commit a7bacb0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .dots/.branch.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ if %ERRORLEVEL% equ 1 exit /b

rem ::: Git branch
rem :::
rem ::: .BRANCH [branch name]
rem ::: .BRANCH [branch name] [--pull]
rem :::
rem ::: Parameters:
rem ::: branch name - full or partial branch name
rem ::: pull - execute git pull immediatelly after the checkout
rem :::
rem ::: Description:
rem ::: Show available branches or switch current branch.
Expand All @@ -25,19 +26,26 @@ echo Checking out %BRANCH_NAME%
git checkout %BRANCH_NAME%
if %ERRORLEVEL% equ 1 goto :find_branch
git branch
call :pull_branch
goto :eof

:find_branch
:: use .checkout command to find and checkout branch
call .checkout %BRANCH_NAME%

:: if branch was found by .checkout exit the script
if %ERRORLEVEL% equ 0 goto :eof
:: if branch was found by .checkout make sure it is up to date and exit the script
if %ERRORLEVEL% equ 0 call :pull_branch&goto :eof

:: fetch before calling checkout again
echo Fetching...
git fetch

:: try one more time to checkout branch
call .checkout %BRANCH_NAME%
goto :eof


:pull_branch
if defined DOT_ARG_PULL git pull
goto :eof

0 comments on commit a7bacb0

Please sign in to comment.