forked from xDrivenDevelopment/xUnitFor1C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkBranchCheckout.cmd
115 lines (100 loc) · 2.4 KB
/
checkBranchCheckout.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
@echo off
rem
rem ’¥áâ¨à®¢ ¨¥ ¯¥à¥ª«îç¥¨ï ¢¥â®ª åà ¨«¨é xUnitFor1C
rem
rem ’ॡ®¢ ¨ï:
rem 1. “áâ ®¢«¥ë© Git. ãâì ª ¥¬ã 室¨âìáï ¢ á¨á⥬®¬ PATH.
rem 2. „®áâ㯠ª á ©âã GitHub - https://github.com/xDrivenDevelopment/xUnitFor1C
rem
rem ਬ¥à ¢ë§®¢ (¯¥à¥ª«î票ï master <-> develop ¨ ®¡à â®):
rem git_xUnitFor1C_check.cmd
rem ¨«¨ (¯¥à¥ª«î票ï master <-> develop <-> ˆ¬ï„®¯‚¥âª¨ ¨ ®¡à â®):
rem git_xUnitFor1C_check.cmd ˆ¬ï„®¯‚¥âª¨
rem
setlocal
if "%1"=="" ( set branch=develop
) else (
set branch=%1
)
rem echo %branch%
set git_cmd=git
if EXIST "%LOCALAPPDATA%\Atlassian\SourceTree\git_local\cmd\git.exe" set git_cmd="%LOCALAPPDATA%\Atlassian\SourceTree\git_local\cmd\git.exe"
set remoteRepo=https://github.com/xDrivenDevelopment/xUnitFor1C.git
rem set remoteRepo=C:\Projects\xUnitFor1C_t1\.git
set repo=%CD%\xUnitFor1C_temp831
rem echo %repo%
rd /S /Q %repo%
if EXIST %repo% (
tskill TGitCache
rd /S /Q %repo%
if EXIST %repo% (
echo ¥ 㤠«®áì 㤠«¨âì ª â «®£ %repo%
exit 1
pause
)
)
md %repo%
%git_cmd% -c diff.mnemonicprefix=false -c core.quotepath=false clone --recursive %remoteRepo% %repo%
set old_branch=master
cd %repo%
%git_cmd% checkout -b develop origin/develop
if errorlevel 1 (
echo .
echo ¥ 㤠«®áì ¯¥à¥ª«îç¨âìáï ¢¥âªã develop ¨§ ¢¥âª¨ %old_branch%
pause
exit 2
)
%git_cmd% status
set old_branch=develop
if not %branch%==develop (
%git_cmd% checkout -b %branch% origin/%branch%
if errorlevel 1 (
echo .
echo ¥ 㤠«®áì ¯¥à¥ª«îç¨âìáï ¢¥âªã %branch% ¨§ ¢¥âª¨ %old_branch%
pause
exit 5
)
%git_cmd% status
set old_branch=%branch%
)
%git_cmd% checkout master
if errorlevel 1 (
echo .
echo ¥ 㤠«®áì ¯¥à¥ª«îç¨âìáï ¢¥âªã master ¨§ ¢¥âª¨ %old_branch%
pause
exit 3
)
%git_cmd% status
set old_branch=master
%git_cmd% checkout develop
if errorlevel 1 (
echo .
echo ¥ 㤠«®áì ¯®¢â®à® ¯¥à¥ª«îç¨âìáï ¢¥âªã develop ¨§ ¢¥âª¨ %old_branch%
pause
exit 4
)
%git_cmd% status
set old_branch=develop
if not %branch%==develop (
%git_cmd% checkout %branch%
if errorlevel 1 (
echo .
echo ¥ 㤠«®áì ¯®¢â®à® ¯¥à¥ª«îç¨âìáï ¢¥âªã %branch% ¨§ ¢¥âª¨ %old_branch%
pause
exit 6
)
%git_cmd% status
set old_branch=%branch%
)
%git_cmd% checkout master
if errorlevel 1 (
echo .
echo ¥ 㤠«®áì ¯®¢â®à® ¯¥à¥ª«îç¨âìáï ¢¥âªã master ¨§ ¢¥âª¨ %old_branch%
pause
exit 7
)
%git_cmd% status
set old_branch=master
endlocal
echo ‚ᥠ¯¥à¥ª«îç¥¨ï § ¢¥à訫¨áì ãᯥè®
exit 0