I want to get output in simple txt file inside git repo folder:
About:
date = (2022_06_04)
version = (1d34a1b1)
And I stuck with formatting data in ( ) brackets.
Here is my attempt:
@echo off
set dt=%DATE:~6,4%_%DATE:~3,2%_%DATE:~0,2%%
set dt=%dt: =0%
set wrap=About:
set file_name="vers.txt"
set git_cmd=git describe --abbrev=8 --always
echo %wrap% >%file_name%
echo.date = (%dt%)>>%file_name%
echo|set /p ="version = (" >>%file_name%
%git_cmd% >>%file_name%
echo.) >>%file_name%
%NL%>>%file_name%
Problem is with ')' for git output formatting. Here is what I'm getting:
About:
date = (2022_06_04)
version = (1d34a1b1
)
I've tried to play with echo -n
, but it doesn't work on Windows.
UPDATE
NL is just new line:
set NL=echo.
Here is example of command line with whole git command output:
USR@DESKTOP-N1 MINGW64 /c/project/prj (v1.1.2)<CR><LF>
$ git describe --abbrev=8 --always<CR><LF>
1d34a1b1<CR><LF>
<CR><LF>
USR@DESKTOP-N1 MINGW64 /c/project/prj (v1.1.2)<CR><LF>
And here is how my output text file looks like:
About:<CR><LF>
date = (2022_06_06)<CR><LF>
version = (1d34a1b1<LF>
) <CR><LF>
Seems <LF>
appeared at some stage. For me it looks like <CR>
was cutted but <LF>
stayed because of some Windows standard formatting or something like that, I'm no sure.