forked from fseguel91/Iris-Builds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_custom_commit.bat
337 lines (287 loc) · 13.6 KB
/
_custom_commit.bat
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
@echo off
SETLOCAL enabledelayedexpansion
REM ////////////////////////////////////////////////////////////
REM
REM ██╗██████╗ ██╗███████╗ ██████╗ █████╗ ████████╗ ███╗ ███╗ █████╗ ██████╗ ██╗ ██████╗
REM ██║██╔══██╗██║██╔════╝ ██╔══██╗██╔══██╗╚══██╔══╝ ████╗ ████║██╔══██╗██╔════╝ ██║██╔════╝
REM ██║██████╔╝██║███████╗ ██████╔╝███████║ ██║ ██╔████╔██║███████║██║ ███╗██║██║
REM ██║██╔══██╗██║╚════██║ ██╔══██╗██╔══██║ ██║ ██║╚██╔╝██║██╔══██║██║ ██║██║██║
REM ██║██║ ██║██║███████║ ██╗██████╔╝██║ ██║ ██║ ██║ ╚═╝ ██║██║ ██║╚██████╔╝██║╚██████╗
REM ╚═╝╚═╝ ╚═╝╚═╝╚══════╝ ╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═════╝
REM
REM ////////////////////////////////////////////////////////////
CALL :DISPLAY_IMAGE IRIS_BAT_MAGIC
REM ////////////////////////////////////////////////////////////
SET current_date_time=%date% %time%
call :IMPORTANT_ECHO "Time: %current_date_time%"
REM ////////////////////////////////////////////////////////////
for %%I in (.) do set current_dir_name=%%~nxI
call :IMPORTANT_ECHO "Directory: %current_dir_name%"
REM ////////////////////////////////////////////////////////////
CALL :NEW_LINE_ECHO
CALL :UNDERLINED_SECTION_ECHO "--- Current repository status... ---"
CALL :NEW_LINE_ECHO
CALL :BOLD_ECHO_AND_RUN "git status"
CALL :NEW_LINE_ECHO
REM ////////////////////////////////////////////////////////////
CALL :NEW_LINE_ECHO
CALL :UNDERLINED_SECTION_ECHO "--- Get the latest Github version of this repository... ---"
CALL :NEW_LINE_ECHO
CALL :BOLD_ECHO_AND_RUN "call pull.bat"
CALL :UNDERLINED_NOTE_ECHO "Doing git pull of the repository and all submodules"
CALL :NEW_LINE_ECHO
REM ////////////////////////////////////////////////////////////
CALL :NEW_LINE_ECHO
CALL :UNDERLINED_SECTION_ECHO "--- Current repository status... ---"
CALL :NEW_LINE_ECHO
CALL :BOLD_ECHO_AND_RUN "git status"
CALL :NEW_LINE_ECHO
REM ////////////////////////////////////////////////////////////
SET commit_message= :hammer: Update %current_dir_name% - %current_date_time%
SET /P commit_message=Enter your commit message:
echo [104mCommit message set to: "%commit_message%"[0m
CALL :NEW_LINE_ECHO
@echo off
REM ////////////////////////////////////////////////////////////
CALL :NEW_LINE_ECHO
CALL :UNDERLINED_SECTION_ECHO "--- Push all changes from this repository to Github... ---"
CALL :NEW_LINE_ECHO
REM ////////////////////////////////////////////////////////
SETLOCAL
CALL :NEXT_COMMAND_ACTION_ECHO "Changing current directory to custom-code/externals/iris-php-utils"
cd custom-code/externals/iris-php-utils
CALL :BOLD_ECHO " - Pushing all changes from this directory to Github"
git add --all
git commit -m "%commit_message%"
git push origin HEAD:master
ENDLOCAL
REM ////////////////////////////////////////////////////////
SETLOCAL
CALL :NEXT_COMMAND_ACTION_ECHO "Changing current directory to custom-code/database"
cd custom-code/database
CALL :BOLD_ECHO " - Pushing all changes from this directory to Github"
CALL :BOLD_ECHO_AND_RUN " git add --all"
echo [1m git commit -m "%commit_message%"[0m
git commit -m "%commit_message%"
CALL :BOLD_ECHO_AND_RUN " git push origin HEAD:master"
ENDLOCAL
REM ////////////////////////////////////////////////////////
SETLOCAL
CALL :NEXT_COMMAND_ACTION_ECHO "Changing current directory to custom-code/iris-defines"
cd custom-code/iris-defines
CALL :BOLD_ECHO " - Pushing all changes from this directory to Github"
CALL :BOLD_ECHO_AND_RUN " git add --all"
echo [1m git commit -m "%commit_message%"[0m
git commit -m "%commit_message%"
CALL :BOLD_ECHO_AND_RUN " git push origin HEAD:master"
ENDLOCAL
REM ////////////////////////////////////////////////////////
CALL :NEXT_COMMAND_ACTION_ECHO "Changing current directory to %current_dir_name%"
CALL :BOLD_ECHO " - Pushing all changes from this directory to Github"
CALL :BOLD_ECHO_AND_RUN " git add --all"
echo [1m git commit -m "%commit_message%"[0m
git commit -m "%commit_message%"
CALL :BOLD_ECHO_AND_RUN " git push origin HEAD:master"
REM Wait until key is pressed is the file was double clicked
REM ////////////////////////////////////////////////////////////
CALL :PAUSE_SCRIPT_IF_DOUBLE_CLICKED
REM ////////////////////////////////////////////////////////////
REM Set functions we are going to use
REM ////////////////////////////////////////////////////////////
REM Function BOLD_ECHO_AND_RUN display param 1 and run it
REM Use it like this:
REM CALL :BOLD_ECHO_AND_RUN "COMMAND_TO_RUN"
REM %~1 means the first argument passes to the functions
REM [1m and other are ANSI Escape Sequences
REM ////////////////////////////////////////////////////////////
:BOLD_ECHO_AND_RUN
echo [1m %~1 [0m
%~1
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:BOLD_ECHO
echo [1m %~1 [0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:GREEN_ECHO
echo [92m %~1 [0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:MAGENTA_ECHO
echo [95m %~1 [0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:UNDERLINED_SECTION_ECHO
echo [4m[92m%~1[0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:UNDERLINED_NOTE_ECHO
echo [4m[93m^^%~1[0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:NEW_LINE_ECHO
echo.
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:NEXT_COMMAND_ACTION_ECHO
echo [96m^> %~1[0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:CYAN_ECHO
echo [96m %~1[0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:NEXT_COMMAND_EXPLANATION_ECHO
echo [0m - %~1[0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:IMPORTANT_ECHO
echo [7m%~1[0m
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:OPEN_PANEL_HELP_PAGE
start "" %HELP_PAGE_URL%
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:IS_GITHUB_USER_EMAIL_SET
SET github_user_email_value=
git config user.email > git_config_check
SET /p github_user_email_value= < git_config_check
DEL git_config_check
REM echo github_user_email_value: %github_user_email_value%
IF DEFINED github_user_email_value (
REM echo github_user_email_value is DEFINED
SET %~1=TRUE
) ELSE (
REM echo github_user_email_value is NOT DEFINED
SET %~1=FALSE
)
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:GET_GITHUB_USER_EMAIL_VALUE
SET github_user_email_value=
git config user.email > git_config_check
SET /p github_user_email_value= < git_config_check
DEL git_config_check
CALL :MAKE_VARIABLE_SAFE github_user_email_value "%github_user_email_value%"
REM echo github_user_email_value: %github_user_email_value%
SET %~1=%github_user_email_value%
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:SET_GITHUB_USER_EMAIL
REM It's a strange fact that you can commit from another persons name https://superuser.com/questions/816341/github-lets-me-commit-as-another-user/1234339. Please don't do this here
SET /p github_user_email=What is your Github Email?:
CALL :MAKE_VARIABLE_SAFE github_user_email "%github_user_email%"
echo [1m git config --global --replace-all user.email %github_user_email%[0m
CALL :UNDERLINED_NOTE_ECHO "This is the user email we commit from"
git config --global --replace-all user.email %github_user_email%
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:IS_GITHUB_USER_NAME_SET
SET github_user_name_value=
git config user.name > git_config_check
SET /p github_user_name_value= < git_config_check
DEL git_config_check
REM echo github_user_name_value: %github_user_name_value%
IF DEFINED github_user_name_value (
REM echo github_user_name_value is DEFINED
SET %~1=TRUE
) ELSE (
REM echo github_user_name_value is NOT DEFINED
SET %~1=FALSE
)
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:GET_GITHUB_USER_NAME_VALUE
SET github_user_name_value=
git config user.name > git_config_check
SET /p github_user_name_value= < git_config_check
DEL git_config_check
CALL :MAKE_VARIABLE_SAFE github_user_name_value "%github_user_name_value%"
REM echo github_user_email_value: %github_user_name_value%
SET %~1=%github_user_name_value%
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:SET_GITHUB_USER_NAME
REM It's a strange fact that you can commit from another persons name https://superuser.com/questions/816341/github-lets-me-commit-as-another-user/1234339. Please don't do this here
SET /p github_user_name=What is your Github Username?:
CALL :MAKE_VARIABLE_SAFE github_user_name "%github_user_name%"
echo [1m git config --global --replace-all user.name %github_user_name%[0m
CALL :UNDERLINED_NOTE_ECHO "This is the user name we commit from"
git config --global --replace-all user.name %github_user_name%
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:PAUSE_SCRIPT_IF_DOUBLE_CLICKED
SETLOCAL enabledelayedexpansion
set current_call_line=%cmdcmdline:"=%
REM echo current_call_line: %current_call_line%
REM echo Current file is: %~nx0
set current_call_line_without_file_name=!current_call_line:%~nx0=!
REM echo current_call_line_without_file_name: %current_call_line_without_file_name%
if not "%current_call_line%" == "%current_call_line_without_file_name%" pause
ENDLOCAL
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:ASK_IF_USER_WANTS_HELP
SET display_help=
SET /p display_help=Skip help page with more info?(Y/N):
IF NOT DEFINED display_help SET "display_help=y"
REM echo You typed: %display_help%
if /i %display_help%==n CALL :OPEN_PANEL_HELP_PAGE
EXIT /B 0
:MAKE_VARIABLE_SAFE
SET variable_to_make_safe="%~2"
REM echo variable_to_make_safe: %variable_to_make_safe%
SET variable_to_make_safe_without_spaces=%variable_to_make_safe: =%
REM echo variable_to_make_safe_without_spaces: %variable_to_make_safe_without_spaces%
IF NOT %variable_to_make_safe%==%variable_to_make_safe_without_spaces% (
REM echo variable HAVE spaces
SET %~1="%~2"
) ELSE (
REM echo variable DOESN'T HAVE spaces
SET %~1=%~2
)
EXIT /B 0
REM ////////////////////////////////////////////////////////////
:DISPLAY_IMAGE
for /f "delims=: tokens=1*" %%A in ('findstr /b ":::%~1:::" "%~f0"') do (echo.%%B)
EXIT /B 0
REM Image definitions are below
REM ////////////////////////////////////////////////////////////
REM ////////////////////////////////////////////////////////////
::IMAGE:PRESS_KEY_TO_CONTINUE::
:::PRESS_KEY_TO_CONTINUE:::
:::PRESS_KEY_TO_CONTINUE::: _ _,---._
:::PRESS_KEY_TO_CONTINUE::: ,-',' `-.___
:::PRESS_KEY_TO_CONTINUE::: /-;' `._
:::PRESS_KEY_TO_CONTINUE::: /\/ ._ _,'o \
:::PRESS_KEY_TO_CONTINUE::: ( /\ _,--'\,','"`. )
:::PRESS_KEY_TO_CONTINUE::: |\ ,'o \' //\
:::PRESS_KEY_TO_CONTINUE::: | \ / ,--'""`-.
:::PRESS_KEY_TO_CONTINUE::: : \_ _/ ,-' `-._
:::PRESS_KEY_TO_CONTINUE::: \ `--' / )
:::PRESS_KEY_TO_CONTINUE::: `. \`._ ,' ________,','
:::PRESS_KEY_TO_CONTINUE::: .--` ,' ,--` __\___,;'
:::PRESS_KEY_TO_CONTINUE::: \`.,-- ,' ,`_)--' /`.,'
:::PRESS_KEY_TO_CONTINUE::: \( ; | | ) (`-/
:::PRESS_KEY_TO_CONTINUE::: `--'| |) |-/
:::PRESS_KEY_TO_CONTINUE::: | | | | |
:::PRESS_KEY_TO_CONTINUE::: | | |,.,-. | |_
:::PRESS_KEY_TO_CONTINUE::: | `./ / )---` )
:::PRESS_KEY_TO_CONTINUE::: _| / ,', ,-'
:::PRESS_KEY_TO_CONTINUE::: ,'|_( /-<._,' |--,
:::PRESS_KEY_TO_CONTINUE::: | `--'---. \/ \
:::PRESS_KEY_TO_CONTINUE::: | / \ /\ \
:::PRESS_KEY_TO_CONTINUE::: ,-^---._ | \ / \ \
:::PRESS_KEY_TO_CONTINUE::: ,-' \----' \/ \--`.
:::PRESS_KEY_TO_CONTINUE::: / \ \ \
:::PRESS_KEY_TO_CONTINUE:::
REM ////////////////////////////////////////////////////////////
REM ////////////////////////////////////////////////////////////
::IMAGE:IRIS_BAT_MAGIC::
:::IRIS_BAT_MAGIC::: __ __ __ ___ __ __
:::IRIS_BAT_MAGIC::: | |__) | /__` |__) /\ | |\/| /\ / _` | / `
:::IRIS_BAT_MAGIC::: | | \ | .__/ .|__) /~~\ | | | /~~\ \__> | \__,
:::IRIS_BAT_MAGIC:::
REM ////////////////////////////////////////////////////////////
REM ////////////////////////////////////////////////////////////