人力検索はてな
モバイル版を表示しています。PC版はこちら
i-mobile

GitとSourceTreeで質問です。 Add Star
差分をzipで圧縮して出力したいと思います。
※環境はWindowsです。

下記をSourceTreeのターミナルで実行すると要望通りのものが生成されますが、

git archive --format=zip HEAD `git diff --name-only HEAD HEAD^` -o archive.zip

いつも入力するのが手間です。
カスタムアクションに登録するにはどのようにすればよいでしょうか?

●質問者: makocan
●カテゴリ:コンピュータ
○ 状態 :終了
└ 回答数 : 2/2件

▽最新の回答へ

1 ● きゃづみぃ
●100ポイント

batファイルにしてから カスタムアクションにしたらどうでしょうか?

http://www.networld.co.jp/is/pdf/CustomActionBatch_.pdf


makocanさんのコメント
見させていただきます!

2 ● a-kuma3
●100ポイント ベストアンサー
git archive --format=zip HEAD `git diff --name-only HEAD HEAD^` -o archive.zip

↑って、バッククォートがあるので、すんなりとはバッチファイルにできないですよね。
試してないですけど、こんな感じのバッチファイルになるんじゃないかと思います。

for /f "delims=" %%A in ('git diff --name-only HEAD "HEAD^"') do set DIFF_LIST=%%A
git archive --format=zip HEAD %DIFF_LIST% -o archive.zip

後、git コマンドは SourceTree に付いてくるものを使ってるでしょうか。
Atlassian の Q&A サイトで こんなやりとりがあったのを見つけましたので、こちらもご参考に。

I've tried putting "git" in the "script target", which errors with no explanation. I've tried putting "cmd" in the script target with "/C git" in the "Parameters" and gotten a "'git' is not recognized" error.

You can add git to your path or specify the path to git.exe in your .bat file.
You should be able to find git.exe here:

%USERPROFILE%\AppData\Local\Atlassian\SourceTree\git_local\bin

How to run a git command as a custom action? - Atlassian Answers

a-kuma3さんのコメント
>> いつも入力するのが手間です。 << ローテクですが、いつものコマンドを単語登録しちゃう、というのもひとつの方法かと。 「さぶんぱっく」とか。

makocanさんのコメント
単語帳登録とは発送の転換に驚きました。頭固いですね。自分。 他の点も試させて頂きます。

makocanさんのコメント
for /f "delims=" %%A in ('git diff --name-only HEAD "HEAD^"') do set DIFF_LIST=%%A git archive --format=zip HEAD %DIFF_LIST% -o archive.zip で十分でした! ありがとうございます。
関連質問

●質問をもっと探す●



0.人力検索はてなトップ
8.このページを友達に紹介
9.このページの先頭へ
対応機種一覧
お問い合わせ
ヘルプ/お知らせ
ログイン
無料ユーザー登録
はてなトップ