8
8
exit /b %errorlevel%
9
9
10
10
:loadenv
11
- exit /b 0
11
+ goto : eof
12
12
13
13
:prepare_project
14
14
if not defined PROJECT (echo Missing PROJECT && exit /b 1)
@@ -35,26 +35,7 @@ exit /b %errorlevel%
35
35
if not [%NO_UPDATE% ] == [true] (
36
36
echo .
37
37
if " %TAG% " == " " (
38
- :: check if we should update project
39
- set GIT_BRANCH = NONE
40
- for /f " usebackq delims=" %%i in (`git symbolic-ref --short -q HEAD`) do (
41
- set GIT_BRANCH = %%i
42
- )
43
- if not [%GIT_BRANCH% ] == [NONE] (
44
- :: check if current branch has a remote
45
- set GIT_REMOTE = NONE
46
- for /f " usebackq delims=" %%i in (`git config --get branch.%GIT_BRANCH% .remote`) do (
47
- set GIT_REMOTE = %%i
48
- )
49
- if not [%GIT_REMOTE% ] == [NONE] (
50
- echo ### Updating project
51
- git pull --ff-only || exit /b 1
52
- ) else (
53
- echo ### NOT updating project [no remote for branch %GIT_BRANCH% ]
54
- )
55
- ) else (
56
- echo NOT updating project [not on branch]
57
- )
38
+ call :update_project
58
39
) else (
59
40
echo ### Checking out %TAG%
60
41
git fetch --tags || exit /b 1
@@ -72,4 +53,40 @@ exit /b %errorlevel%
72
53
git apply %%P
73
54
)
74
55
75
- exit /b 0
56
+ goto :eof
57
+
58
+ :update_project
59
+ :: check if we should update project
60
+ set GIT_BRANCH = NONE
61
+ for /f " usebackq delims=" %%i in (`git symbolic-ref --short -q HEAD`) do (
62
+ call :set_git_branch %%i
63
+ )
64
+ if not [%GIT_BRANCH% ] == [NONE] (
65
+ call :update_project_2
66
+ ) else (
67
+ echo NOT updating project [not on branch]
68
+ )
69
+ goto :eof
70
+
71
+ :update_project_2
72
+ :: check if current branch has a remote
73
+ set GIT_REMOTE = NONE
74
+ for /f " usebackq delims=" %%i in (`git config --get branch.%GIT_BRANCH% .remote`) do (
75
+ call :set_git_remote %%i
76
+ )
77
+ if not [%GIT_REMOTE% ] == [NONE] (
78
+ echo ### Updating project
79
+ git pull --ff-only || exit /b 1
80
+ ) else (
81
+ echo ### NOT updating project [no remote for branch %GIT_BRANCH% ]
82
+ )
83
+ goto :eof
84
+
85
+ :set_git_branch
86
+ set GIT_BRANCH = %1
87
+ goto :eof
88
+
89
+ :set_git_remote
90
+ set GIT_REMOTE = %1
91
+ goto :eof
92
+
0 commit comments