Last active
November 16, 2015 08:24
-
-
Save tAkihiko/f26f461f78d0ceb7f002 to your computer and use it in GitHub Desktop.
Windows向けGitの差分アーカイブ、日本語対応版
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
:: 要Windows用nkf, git config core.quotepath false | |
for /f "usebackq" %%a in (`git rev-parse --abbrev-ref HEAD`) do set cbname=%%a | |
set bk_date=%DATE:~0,10% | |
set bk_date=%bk_date:/=% | |
::set bk_time=%TIME: =0% | |
::set bk_time=%bk_time:~0,5% | |
::set bk_time=%bk_time::=% | |
:: 必ず出力するファイル | |
set must_export_files="export-subst指定したファイルなど.txt" | |
if #%2# == ## ( | |
if #%1# == ## ( | |
set target=%cbname% | |
set base=master | |
) else ( | |
set target=%cbname% | |
set base=%1 | |
) | |
) else ( | |
set target=%2 | |
set base=%1 | |
) | |
for /f "usebackq" %%a in (`git --no-pager log --pretty^=%%h -1 %base%`) do set base_hash=%%a | |
for /f "usebackq" %%a in (`git --no-pager log --pretty^=%%h -1 %target%`) do set target_hash=%%a | |
set file_list= | |
for /f "usebackq delims=;" %%a in (`git --no-pager diff -M -C --name-only %base% %target% ^| nkf -s`) do set file_list=!file_list! "%%a" | |
git archive --verbose --format=zip %target% --prefix=%base_hash%_%target_hash%/ --output _archive_%bk_date%_%base_hash%_%target_hash%.zip -- %file_list% %must_export_files% | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment