5

After checking out a new branch, I wanted to stop tracking of files like .classpath via Atlassian SourceTree (Version 1.4.0.0). I created a custom action with the details below:

enter image description here

Then, from the "Working Copy changes" panel, I selected a file, right-clicked on it and tried to execute "assume unchanged" custom command. However, I got this totally "scrimpy" error message:

enter image description here

I copied the full command in the error message above and tried to execute it from the command line:enter image description here

Interestingly, it worked.

Can someone tell me why this custom action didn't work at first place via right clicking and selecting from the menu?

Juvanis
  • 25,802
  • 5
  • 69
  • 87

4 Answers4

2

This is interesting. I just noticed this issue on my own setup when a previously working git-based command now no longer worked. I assume something has changed in the more recent version of SourceTree. I believe the issue is now invoked commands won't get the complete environment setup configured just as one might expect when opening a terminal from SourceTree. The Completed with errors message is a result of the command not being found.

For my own setup, I work around this issue by building my custom actions with the cmd process. For example:

  • Caption: Full Index Patch for Selected Commit
  • Script to run: cmd

With parameters:

/c %LOCALAPPDATA%\Atlassian\SourceTree\git_local\bin\sh.exe --login -i -c 'git format-patch --full-index -1 $SHA'

Another example:

  • Caption: Full Index Patch for Working Index
  • Script to run: cmd

With parameters:

/c %LOCALAPPDATA%\Atlassian\SourceTree\git_local\bin\sh.exe --login -i -c ^"git diff --full-index --cached > patch.diff^"

(these examples assume you're using the embedded Git in SourceTree)

Using SourceTree 1.6.12 and Git 1.8.3.

jdknight
  • 1,801
  • 32
  • 52
0

Check if $FILE represents the full complete path of the file you selected.
It seems to be presented that way in "Custom actions – more power to you" (Feb. 2012, when custom actions were introduced to Atlassian Source Tree 1.3+).

If that is the case, using $FILE instead of C:/Repository/$FILE should be enough.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I double checked my paths, $FILE represents the relative path of the selected file, that's why I added the repository path as a prefix. Additionally, I already mentioned that the command (which appears in the error message) generated by the custom action works when I copy and paste it to the command line. That's the strange thing! – Juvanis Jul 21 '14 at 12:08
  • Ok. Can you try it with $ FILE alonz though, just for testing? – VonC Jul 21 '14 at 12:10
  • before trying with the repositoryPath+$FILE, I already tested with $FILE alone and it didn't work. To clarify, how can a command work from command line while it doesn't work via the UI? – Juvanis Jul 21 '14 at 12:18
  • @Juvanis It says "completed with errors, see above": is there any error message? – VonC Jul 21 '14 at 12:22
  • that's why I called the error message as "scrimpy" in my post. the error message is just that :) – Juvanis Jul 21 '14 at 12:28
  • And just to test, would a `git` / `log -1 $REPO/$FILE` work better? – VonC Jul 21 '14 at 12:29
  • And did you select the "Show full output" option in that dialog box? – VonC Jul 21 '14 at 12:30
  • "Show full output" was selected, sir. don't worry, I have done all trivial things. – Juvanis Jul 21 '14 at 12:31
0

I recently got some custom actions in Windows with SourceTree Custom Action:

git stash + pull + unstash in Windows

Script to run: cmd
Parameters: /c %LOCALAPPDATA%\Atlassian\SourceTree\git_local\bin\sh.exe -c -e 'alias git=/c/Users/%username%/AppData/Local/Atlassian/SourceTree/git_local/cmd/git.exe; git stash; git pull --rebase; git stash pop'

This handles if you have multiple versions of git installed, and exits early if it fails mid-way.

git stash + pull + unstash in MacOS

The rough equivalent in MacOS looks like:

Script to run: /path/to/stash_unstash.sh
Parameters: $REPO

stash_unstash.sh

#!/usr/bin/env bash

cd $1
git stash && git pull --rebase && git stash pop
phyatt
  • 18,472
  • 5
  • 61
  • 80
0

macOS - Custom Action:

Script to run: /bin/bash

Parameters:

cd $REPO && git stash && git pull && git stash pop

cd $REPO && git stash && git pull --rebase && git stash pop

hstdt
  • 5,652
  • 2
  • 34
  • 34