SourceTree custom action doesn't work but works through Git terminal window

Viewed 2754

I'm trying to setup Source Tree custom Git action to extract and zip files for deploy from selected commit till the HEAD, excluding deleted files with --diff-filter.

archive -o deploy.zip HEAD $(git diff --name-only --diff-filter=ACMR $SHA)

Source Tree custom action screenshot

The problem is that this Git command works perfectly through Git terminal window without error but when I try to use it in Source Tree I get this error.

git archive -o deploy.zip HEAD $(git diff --name-only --diff-filter=ACMR fbf360c607b01fc8c504c9fcf98114eb4bc1896c) error: unknown option name-only

Source Tree custom action error message screenshot

I've tried to figure out what is the problem with this issue, but without success. I would like to hear if anybody had this or similar problem in Source Tree because it looks like a bug to me.

2 Answers

For Windows machines especially, it seems you need one more step from @max630's answer. Put your command in a script (e.g. c:\scripts\deploy.sh)

#!/bin/sh
git archive -o deploy.zip HEAD $(git diff --name-only --diff-filter=ACMR "$1")

Setup the custom action as follows:

  • Script to run: Select bash.exe from the browse window, it might be in:

    C:\Users\{user}\AppData\Local\Atlassian\SourceTree\git_local\bin\bash.exe

  • Parameters: --login -i c:\scripts\deploy.sh

    (the --login -i is shown briefly when you open the Terminal)

  • Check Show Full Output and Run command silently to see the output in the action box, uncheck Show Full Output to hide it unless clicked while running.

It may be useful to add the following to the script to pause the screen to see any error messages (with Open in an Separate Window checked, I believe)

read -p "Press [Enter] key to continue..."

Related