Created
July 3, 2019 06:45
-
-
Save evenv/d351cf256b01ef2d6e356a519f19f65c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal enabledelayedexpansion | |
REM Get the chosen branch as a variable (Default: current branch) | |
if [%2%]==[] ( | |
git rev-parse --abbrev-ref HEAD > tmpFile | |
set /p git_branch=<tmpFile | |
del tmpFile | |
) else ( | |
set git_branch=%2 | |
git checkout dev | |
git pull origin dev | |
git checkout -B !git_branch! | |
) | |
REM Check if branch exists in remote repository | |
git ls-remote origin --head %git_branch% > tmpFile | |
set /p remote_branch=<tmpFile | |
del tmpFile | |
REM Sync with Git remote | |
if "%remote_branch%"=="" ( | |
git push -u origin %git_branch% | |
) else ( | |
git pull origin %git_branch% | |
) | |
REM Import the current local branch to DBC | |
if %1%==up ( | |
databricks workspace delete -r /%git_branch% | |
databricks workspace import_dir src /%git_branch% -o | |
) | |
REM Export the current branch to local | |
if %1%==down ( | |
rmdir /Q /S src | |
databricks workspace export_dir /%git_branch% src -o | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment