Atlassian SourceTree custom action contrast - eclipse

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:
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:
I copied the full command in the error message above and tried to execute it from the command line:
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?

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.

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.

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

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

Related

How can I start GitKraken from the command line with a Git repository path on Windows?

I'd like to create a bunch of shortcuts to open Git repository
GitKraken starts like this:
C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe"
I tried to just add the path like this, but nothing happened:
C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe \"C:\<path to repo with spaces>\MyRepo1\""
C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe \"C:\<path to repo with spaces>\MyRepo2\""
C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe \"C:\<path to repo with spaces>\MyRepo3\""
There could be multiple problems:
GitKraken might not support a path as parameter. Didn't find any documentation when I googled for "gitkraken from command line with repository path as parameter"
Quotes within quotes might be wrong, but I think it's correct: Command line passing quotes within quotes
The command line syntax might be different, but as mentioned above, I didn't find any documentation. I tried "-p" because I saw something similar while googling but it didn't work either C:\Users\<username>\AppData\Local\gitkraken\Update.exe --processStart "gitkraken.exe -p \"C:\<path to repo with spaces>\MyRepo1\""
GitKraken uses the Squirrel.Windows project for installation and update management for it's Windows installs. So the update.exe that is running when you click on the shortcut labeled "GitKraken" is running the Squirrel.Windows process that checks for and downloads updates and then runs the newest version of GitKraken. Once that check is complete, it launches the GitKraken.exe and starts the program.
To solve your issue you will need to pass a CLI option through the Squirrel call into the the gitkraken.exe. You are correct that gitkraken.exe accepts the -p | --path option for the repo to open at launch (e.g. gitkraken.exe -p "\path\to\repo"). If you run it from the app folder directly, you can see the options available at gitkraken.exe --help. Luckily, there are a couple of as-yet undocumented options you can pass that do the pass-through for you (referenced here) so your custom shortcut could now be:
..\Update.exe --processStart "gitkraken.exe" --process-start-args="--path \"d:\path with spaces\to\repo\""
Re: persistence through GitKraken executable updates- OP has confirmed in comments after GitKraken updated to v4.2 that the shortcuts they set up continued to work!
This is what working for me in Ubuntu Desktop
Define it
gkk() { # gkk aka gitkraken
repo_d=$1
if [ -z $repo_d ]; then repo_d=`pwd`; fi
if [ ! -d $repo_d ]; then echo "Invalid :repo_d at $repo_d"; exit 1; fi
/usr/bin/gitkraken -p $repo_d &
}
Use it
cd /path/to/your/repo
gkk
Note, calling the command again on 2nd repo will NOT work!
The workaround I can think of is to close and reopen GitKraken app

Running .sh file on Windows 10 command prompt using cygwin

I am trying to change the author name of the pushed commits on GitHub. I am following the instructions here step by step: https://help.github.com/articles/changing-author-info/#platform-windows but I am stuck at step 3. I am currently using the command prompt on Windows to do it.
#!/bin/sh
git filter-branch --env-filter $' OLD_EMAIL=“yongjeffrey#hotmail.com" CORRECT_NAME=“Jeffrey Yong" CORRECT_EMAIL=“jeffreyyong10#gmail.com" if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" fi if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then
export GIT_AUTHOR_NAME="$CORRECT_NAME" export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" fi ' --tag-name-filter cat -- --branches --tags
So I literally copied and pasted the code above in my command prompt and pressed enter but it seems like there's an error. I already have Cygwin installed and I am wondering what is the best way to run the code above.
Create a file named shellpro.sh with the above code in your project directory
Open cygwin
Browse to the project directory using cd command
Type bash shellpro.sh to execute your script
Or you can simply create the file in the project folder and double click it to execute it with git-bash (CygWin in windows)
I realize this is somewhat ancient but I hit this issue. Git for Windows's bash environment on Windows 10 is a custom Cygwin environment (it seems).
I did the following to get some information on how Git sees it's environment when inside filter-branch:
git filter-branch --env-filter "printenv; echo" -- HEAD~..HEAD
This shows all sorts of handy paths like OLDPWD. But I think it's safest to put your script somewhere in your PATH.
So let's say %USERPROFILE%\bin is in your path go and you put your script in %USERPROFILE%\bin\filterscript.sh
#!/bin/bash
OLD_EMAIL="yongjeffrey#hotmail.com"
CORRECT_NAME="Jeffrey Yong"
CORRECT_EMAIL="jeffreyyong10#gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
You can then invoke it like this:
git filter-branch --env-filter "source filterscript.sh" --tag-name-filter cat -- --branches --tags
Note the use of source. The script needs to be sourced otherwise the environment changes will be lost with the child shell executing the script terminates. Sourcing makes the sh instance that will later execute the commit get the environment changes. It's particularly painful if source is omitted because when debugging it seems that the script is indeed executing (and it is) but not in the right shell.

Post-commit hook failed (exit code 3) with output

I'm trying to call a Jenkins job remotely using a post-commit script. I'm currently committing code through Eclipse Kepler/Subversive/SVNKit Connector.
post-commit script:
if svnlook dirs-changed -r "$REV" "$REPOS" | grep -qEe '^trunk/'; then
wget --post-data="job=APS-RemoteServerAction&token=SECRET&ACTION=deploy&ASSET_NAME=POST-COMMIT-TEST&DEPLOY_ENV=DEV&REVISION=$REV" "http://my.domain.com:8080/buildByToken/buildWithParameters"
fi
Screenshot of error through Eclipse:
Important notes:
Code does get committed properly, repository browser indicates a new version
The job runs on Jenkins, the history shows that
Everytime I commit, I get this error message
I tried adding the flag --quiet, but I got the same exit code.
I'm thinking it's due to wget and posting the values?
Edit #1
I would like to point out that I'm using the Jenkins Build Authorization Token Root Plugin. I switched to a POST instead of a GET (which works) due to eventually moving onto https and keeping the token out of the URL.
I interpret the error message to mean that wget can not write a file with the name buildWithParameters in its current directory. Use wget -O - to write the output to stdout.
The error is (I think) because it's trying to download the webpage to a local dir. You just need to ping the endpoint to make jenkins build, so I used the --spider (doesn't download), --no-proxy (I was getting cached responses sometimes) and -q (don't output, cuz svn will report it).
wget --post-data="job=APS-RemoteServerAction&token=SECRET&ACTION=deploy&ASSET_NAME=POST-COMMIT-TEST&DEPLOY_ENV=DEV&REVISION=$REV" "http://my.domain.com:8080/buildByToken/buildWithParameters" --spider --no-proxy -q

Unable to push using Eclipse/Egit to repository over SSH with git-receive-pack and git-upload-pack set

The title pretty much says it all:
I'm using Eclipse (Juno SR2) with the EGit plugin (2.2.0).
I have a remote repository set up using SSH, and because gitd is not setup on the remote, and because the git tools are not on the path, I have the the following settings in the config file:
[remote "origin"]
url = ssh://moi#fully.qualified.host/home/colleague/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
uploadpack = ~colleague/bin/git-upload-pack
receivepack = ~colleague/bin/git-receive-pack
Doing a plain git push from the command line displays the server's security warning then prompts me for my ssh password, then pushes flawlessly.
However inside Eclipse, I get a popup with the server warning, then I am prompted for my password as before, all appears well, then the final confirmation with the list of commits pushed is empty with an error at the top of
ssh://moi#fully.qualified.host/home/colleague/repo.git: push not permitted
I'm inside a new branch that has not been pushed to the remote as yet, if that makes any difference.
Anyone seen this before?
For anyone that follows down the same rabbit hole after me...
I have found a workaround. You can't set the location of the receive and upload packs in the repository config, so this has to be removed from your config:
[remote "origin"]
receivepack = /blah/bin/git-receive-pack
uploadpack = /blah/bin/git-upload-pack
I'm using the Bash shell remotely, and at the start of .bashrc before it exits when the shell is non-interactive, the location gets added to the path like so:
# If not running interactively, most of what follows is not worth doing
if [ -z "$PS1" ] ; then
# Make sure my extra stuff is on the path even in non-intaractive shells (I'm looking at you SSH!)
export PATH=/blah/bin:$PATH
return
fi
I can now push from either the local command line or via Eclipse/EGit. But of course I have reduced the security of my non-interactive shells as a compromise.

Unable to execute git command in Perl

Hi! I have no problem running
git log --grep="cherry picked" --all > cherrypicklog.txt
from the command line. However it failed to execute in Perl.
my $result = `git log --grep="cherry picked from commit" --all > cherrypicklog.txt`;
git is not recognized as an internal or external command, operable program or batch file.
What am I missing? Thank you.
I don't know much perl at all but I think this is just a general case of git not being in the PATH environment from your perl script. Try using an absolute path:
my $result = `/path/to/bin/git log --grep="cherry picked from commit" --all > cherrypicklog.txt`;