This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tools): add batch script to archive branch
- Loading branch information
1 parent
1e26439
commit f6c8882
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
@ECHO OFF | ||
REM archive-branch.bat | ||
REM Usage: archive-branch <your-branch-name> | ||
|
||
:TopOfScript | ||
ECHO. | ||
ECHO Starting... | ||
|
||
IF "%~1"=="" ( | ||
ECHO This command requires 1 input argument. | ||
ECHO. | ||
ECHO Usage: archive-branch ^<your-branch-name^> | ||
|
||
GOTO :EndOfScript | ||
) | ||
|
||
ECHO. | ||
ECHO * 1. Get local branch from remote, if needed | ||
ECHO. | ||
git checkout %1 | ||
IF %ERRORLEVEL% neq 0 GOTO :Err | ||
|
||
ECHO. | ||
ECHO * 2. Go back to master | ||
ECHO. | ||
git checkout master | ||
IF %ERRORLEVEL% neq 0 GOTO :Err | ||
|
||
ECHO. | ||
ECHO * 3. Create local tag | ||
ECHO. | ||
git tag archive/%1 %1 | ||
IF %ERRORLEVEL% neq 0 GOTO :Err | ||
|
||
ECHO. | ||
ECHO * 4. Create remote tag | ||
ECHO. | ||
git push origin archive/%1 | ||
IF %ERRORLEVEL% neq 0 GOTO :Err | ||
|
||
ECHO. | ||
ECHO * 5. Delete local branch | ||
ECHO. | ||
git branch -d %1 | ||
IF %ERRORLEVEL% neq 0 GOTO :Err | ||
|
||
ECHO. | ||
ECHO * 6. Delete remote branch | ||
ECHO. | ||
git push origin --delete %1 | ||
IF %ERRORLEVEL% neq 0 GOTO :Err | ||
|
||
GOTO :EndOfScript | ||
|
||
:Err | ||
ECHO Errors encountered during execution. Last command exited with status: %ERRORLEVEL%. | ||
|
||
:EndOfScript | ||
ECHO. | ||
ECHO Finished |