-
Notifications
You must be signed in to change notification settings - Fork 6
/
git-commit-adjust-output.bat
162 lines (134 loc) · 3.93 KB
/
git-commit-adjust-output.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
@echo off
setlocal enabledelayedexpansion enableextensions
@rem git config --global user.email "[email protected]"
@rem git config --global user.name "Your Name"
set GITCMD=C:\mix\Git\bin\git.exe
set qa_root=%~dp0
set file_ext=^<pytest_file^>
set git_text=Updated "!file_ext!": adjust expected stdout/stderr to current FB version.
if .%1.==.. goto syntax
set pytest_file=%1
if NOT .%2.==.. (
set /a i=0
@rem echo all inp arguments: ^|"%*"^|
for /f "tokens=1* delims= " %%a in ("%*") do (
set customer_comment=%%b
)
@rem echo customer comment: ^|!customer_comment!^|
set git_text=Added/Updated "!file_ext!": !customer_comment!
)
set joblog=%~dpn0.log
set tmplog=%~dpn0.tmp
del !joblog! 2>nul
del !tmplog! 2>nul
for /f %%a in ("!pytest_file!") do (
@rem set file_ext=%%~nxa
set file_ext=%%a
set text_chk=!file_ext:%qa_root%=!
if .!text_chk!.==.!file_ext!. (
@rem .fbt was specified WITHOUT path
set file_ext=%cd%\!file_ext!
)
set file_ext=!file_ext:%qa_root%=!
)
set git_text=!git_text:^<pytest_file^>=%file_ext%!
(
echo Log for: %~f0 !pytest_file!
echo Created !date! !time! on host '%COMPUTERNAME%'
echo.
echo Comment is: git_text=!git_text!
) >>!joblog!
set msg=!date! !time! Processing command: !GITCMD! add !pytest_file!
echo !msg!
echo !msg!>>!joblog!
@rem ############################
@rem ### g i t a d d ###
@rem ############################
!GITCMD! add !pytest_file! 1>!tmplog! 2>&1
set /a elevel=!errorlevel!
echo elevel=!elevel!
echo elevel=!elevel!>>!joblog!
type !tmplog!
type !tmplog! >>!joblog!
if !elevel! GTR 0 (
echo ERROR OCCURED. Check log:
echo -------------------------
type !tmplog!
echo -------------------------
del !tmplog!
goto :final
)
!GITCMD! status !pytest_file! 1>>!joblog! 2>&1
set msg=!date! !time! Processing command: !GITCMD! commit -m "!git_text!" -- !pytest_file!
echo !msg!
echo !msg!>>!joblog!
@rem ##################################
@rem ### g i t c o m m i t ###
@rem ##################################
!GITCMD! commit -m "!git_text!" -- !pytest_file! 1>!tmplog! 2>&1
set elevel=!errorlevel!
echo elevel=!elevel!
echo elevel=!elevel!>>!joblog!
type !tmplog! >>!joblog!
if !elevel! GTR 0 (
echo ERROR OCCURED. Check log:
echo -------------------------
type !tmplog!
echo -------------------------
del !tmplog!
goto :final
)
set msg=!date! !time! Processing command: !GITCMD! push
echo !msg!
echo !msg!>>!joblog!
@rem ##############################
@rem ### g i t p u s h ###
@rem ##############################
!GITCMD! push 1>!tmplog! 2>&1
set elevel=!errorlevel!
echo elevel=!elevel!
echo elevel=!elevel!>>!joblog!
type !tmplog! >>!joblog!
if !elevel! GTR 0 (
echo ERROR OCCURED. Check log:
echo -------------------------
type !tmplog!
echo -------------------------
del !tmplog!
goto :final
)
del !tmplog! 2>nul
echo ------ OVERALL LOG: --------
type !joblog!
echo ----------------------------
set msg=!date! !time! Check result of commits here:
echo !msg!
!GITCMD! config --get remote.origin.url
(
echo !msg!
!GITCMD! config --get remote.origin.url
) >> !joblog!
@rem #######################################
@rem ### s e n d i n g m a i l ###
@rem #######################################
call %~dp0qa-sendmail.bat "!git_text!" !joblog!
@rem https://github.com/FirebirdSQL/fbt-repository.git
goto final
:syntax
echo.
echo Syntax:
echo 1. %~f0 ^<pytest_file^>
echo.
echo. Commit will be done with comment:
echo. !git_text!
echo.
echo.
echo 2. %~f0 ^<pytest_file^> some very clever comment here
echo.
echo. Commit will be done with comment:
echo. some very clever comment here
echo.
pause
goto final
:final
echo Bye-bye from %~f0