1@echo off 2:: Copyright (C) 2017 Ken Takata 3:: License: GPL-2 or later 4 5setlocal 6 7if "%1"=="" ( 8 echo Usage: gen-repoinfo ^<headerfile^> 9 goto :eof 10) 11set repoinfo_header=%1 12 13set oldinfo= 14if exist %repoinfo_header% ( 15 for /f "delims=" %%i in (%1) do set oldinfo=%%i 16) else ( 17 type nul > %repoinfo_header% 18) 19 20set newinfo=%oldinfo% 21if exist .git ( 22 for /f %%i in ('cmd /c "git describe --tag --exact-match HEAD 2> nul || git rev-parse --short HEAD"') do set newinfo=#define CTAGS_REPOINFO "%%i" 23) 24 25if not "%newinfo%"=="%oldinfo%" echo %newinfo%> %repoinfo_header% 26