Last active
October 14, 2018 09:57
-
-
Save katsuobushiFPGA/9711d4884e543aee4c5b53b7cb74bbc1 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# archive.sh | |
# 変更後 変更前ソースの差分を格納するシェルです。 | |
# | |
# 引数1 : 抽出したいコミットID from | |
# 引数2 : 抽出したいコミットID to | |
# 引数3 ファイルのzip名 | |
# 引数4 プロジェクトフォルダのフルパス | |
# 作業用ディレクトリ ここに吐かせる | |
WORK_DIR='C:/tmp' | |
cd $4 | |
#差分リスト | |
git diff --stat-width=800 --name-status $1 $2 > $WORK_DIR/diff_list.txt | |
# 変更後ソースの格納 | |
git archive $2 --format=zip --prefix=fix/ `git diff --diff-filter=ACMR --name-only $1 $2` -o $WORK_DIR/$3_fix.zip | |
# 変更前ソースの格納 | |
git archive $1 --format=zip --prefix=org/ `git diff --diff-filter=ACMR --name-only $1 $2` -o $WORK_DIR/$3_org.zip | |
cd $WORK_DIR | |
unzip $3_fix.zip | |
unzip $3_org.zip | |
#格納フォルダ作成 | |
zip $3.zip -r fix org diff_list.txt | |
#不要ファイル削除 | |
rm -fR fix/ | |
rm -fR org/ | |
rm -f $3_fix.zip | |
rm -f $3_org.zip | |
rm -fR $3/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment