Skip to content

Commit

Permalink
add branch names to the header
Browse files Browse the repository at this point in the history
  • Loading branch information
halyna-dev committed Nov 29, 2020
1 parent 3a99da9 commit 38a641c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 68 deletions.
13 changes: 10 additions & 3 deletions niceDiff.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ SET branchA=%1
SET branchB=%2
SET comparePath=%3

::validate 1st parametr
:: validate 1st parametr
IF "%branchA%"=="" (
echo %me%: incorrect parameters. Please use: niceDiff ^<branch1-name^> ^<branch2-name^> [optional ^<path-to-comparing-files^>]
GOTO:EOF
)

::validate 2nd parametr
:: validate 2nd parametr
IF "%branchB%"=="" (
echo %me%: incorrect parameters. Please use: niceDiff ^<branch1-name^> ^<branch2-name^> [optional ^<path-to-comparing-files^>]
GOTO:EOF
Expand All @@ -27,5 +27,12 @@ git diff --minimal %branchA% %branchB% %3 > %parent%/diff.txt
:: note: --minimal flag get line different, --word-diff is nuclear diff

:: parce file into html
call parceDiff.bat

:: add top part of template
TYPE %parent%template_top_report.html> niceDiff-report.html
:: add branches to the header
SET svgBranch="data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHZpZXdCb3g9IjAgMCAxNzIgMTcyIj48ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9Im5vbnplcm8iIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBzdHJva2UtbGluZWNhcD0iYnV0dCIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiBzdHJva2UtZGFzaGFycmF5PSIiIHN0cm9rZS1kYXNob2Zmc2V0PSIwIiBmb250LWZhbWlseT0ibm9uZSIgZm9udC13ZWlnaHQ9Im5vbmUiI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TgwNGMxLjU4NzA2LC0xLjU0NTY2IDIuMDYzMzYsLTMuOTA2NjYgMS4xOTk2NiwtNS45NDY3MmMtMC44NjM3LC0yLjA0MDA3IC0yLjg5MDQ4LC0zLjM0MTM0IC01LjEwNDkzLC0zLjI3NzU2eiI+PC9wYXRoPjwvZz48L2c+PC9zdmc+"
ECHO ^<p id="branches"^> ^<img src=%svgBranch% width="18" height="18"^> %branchA% ^< %branchB% ^</p^>>> niceDiff-report.html

call parseDiff.bat

124 changes: 62 additions & 62 deletions parceDiff.bat → parseDiff.bat
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
ECHO start parcing...

::add top part of template
TYPE %parent%template_top_report.html> niceDiff-report.html

SET parent=%~dp0

::CONSTANTS
SET sOpenFile=^</div^>^<button class="section"^>
SET sCloseFile=^</button^>^<div class="section-content"^>^<div^>
SET sOpenCodeBlock=^</div^>^<div^>
SET sOpenCodeLine=^<pre^>
SET sCloseCodeLine=^</pre^>
SET sOpenAddCodeLine=^<pre class="add"^>
SET sOpenRemoveCodeLine=^<pre class="remove"^>

::init code block
ECHO ^<div^>>> niceDiff-report.html
::init file section
ECHO ^<div^>>> niceDiff-report.html

SETLOCAL enabledelayedexpansion
FOR /F "usebackq tokens=*" %%A IN ("%parent%/diff.txt") DO (
SET line1=%%A
SET line2=!line1:^<=^&lt;!
SET line=!line2:^>=^&gt;!
IF "!line:~0,10!"=="diff --git" (
rem close last code block in previous file
ECHO ^</div^>>> niceDiff-report.html
rem new file
ECHO !sOpenFile! >> niceDiff-report.html
) ELSE IF "!line:~0,5!"=="--- a" (
rem get file name
ECHO !line:~5!!sCloseFile! >> niceDiff-report.html
) ELSE IF "!line:~0,5!"=="+++ b" (
rem skip line
) ELSE IF "!line:~0,6!"=="index " (
rem skip line
) ELSE IF "!line:~0,3!"=="@@ " (
rem start diff block
ECHO !sOpenCodeBlock!!sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html
) ELSE IF "!line:~0,1!"=="-" (
rem start remove line
ECHO !sOpenRemoveCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html
) ELSE IF "!line:~0,1!"=="+" (
rem start add line
ECHO !sOpenAddCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html
) ELSE (
rem default add line
ECHO !sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html
)
)
::close last code block
ECHO ^</div^>>> niceDiff-report.html
::close file section
ECHO ^</div^>>> niceDiff-report.html

::add bottom part of template
TYPE %parent%template_bottom_report.html>> niceDiff-report.html

ECHO complited

ECHO start parcing...

SET parent=%~dp0

:: CONSTANTS
SET sOpenFile=^</div^>^<button class="section"^>
SET sCloseFile=^</button^>^<div class="section-content"^>^<div^>
SET sOpenCodeBlock=^</div^>^<div^>
SET sOpenCodeLine=^<pre^>
SET sCloseCodeLine=^</pre^>
SET sOpenAddCodeLine=^<pre class="add"^>
SET sOpenRemoveCodeLine=^<pre class="remove"^>

:: open tag for main cotent
ECHO ^<main^>>>niceDiff-report.html

:: init code block
ECHO ^<div^>>> niceDiff-report.html
:: init file section
ECHO ^<div^>>> niceDiff-report.html

SETLOCAL enabledelayedexpansion
FOR /F "usebackq tokens=*" %%A IN ("%parent%/diff.txt") DO (
SET line1=%%A
SET line2=!line1:^<=^&lt;!
SET line=!line2:^>=^&gt;!
IF "!line:~0,10!"=="diff --git" (
rem close last code block in previous file
ECHO ^</div^>>> niceDiff-report.html
rem new file
ECHO !sOpenFile! >> niceDiff-report.html
) ELSE IF "!line:~0,5!"=="--- a" (
rem get file name
ECHO !line:~5!!sCloseFile! >> niceDiff-report.html
) ELSE IF "!line:~0,5!"=="+++ b" (
rem skip line
) ELSE IF "!line:~0,6!"=="index " (
rem skip line
) ELSE IF "!line:~0,3!"=="@@ " (
rem start diff block
ECHO !sOpenCodeBlock!!sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html
) ELSE IF "!line:~0,1!"=="-" (
rem start remove line
ECHO !sOpenRemoveCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html
) ELSE IF "!line:~0,1!"=="+" (
rem start add line
ECHO !sOpenAddCodeLine!!line:~1!!sCloseCodeLine! >> niceDiff-report.html
) ELSE (
rem default add line
ECHO !sOpenCodeLine!!line!!sCloseCodeLine! >> niceDiff-report.html
)
)
:: close last code block
ECHO ^</div^>>> niceDiff-report.html
:: close file section
ECHO ^</div^>>> niceDiff-report.html

:: add bottom part of template
TYPE %parent%template_bottom_report.html>> niceDiff-report.html

ECHO complited

10 changes: 7 additions & 3 deletions template_top_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
color: #50e0d9;
font-size: 26px;
}
#branches {
display: flex;
padding: 10px 50px;
color: #999;
background-color: white;
}
button {
height: 30px;
width: 100%;
Expand Down Expand Up @@ -99,7 +105,7 @@

<header>
<h2>Report </h2>
<a target="_blank" class="icon" href="https://github.com/">
<a target="_blank" class="icon" href="https://github.com/halyna-dev/niceDiff">
<i aria-label="icon: github" class="anticon anticon-github">
<svg viewBox="64 64 896 896" class="" data-icon="github" width="1em" height="1em" fill="currentColor"
aria-hidden="true" focusable="false">
Expand All @@ -108,5 +114,3 @@ <h2>Report </h2>
</i>
</a>
</header>

<main>

0 comments on commit 38a641c

Please sign in to comment.