Skip to content

nwinkler/sourcetree-stash-custom-actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

sourcetree-stash-custom-actions

Custom Actions for working with Stash from SourceTree.

These are currently supported on Mac OS X and Windows.

Provided Functionality

The custom actions provided in this repository help with automating some actions when working with repositories hosted on Stash in SourceTree. The main work done here is to translate the URLs used by Stash for the Git endpoint to URLs that work with the Stash web UI.

An example:

The custom action scripts in this repo translate the URLs and allow you to go from a local commit directly to the same commit in the web UI.

Copy Commit Message

This custom action copies the commit message of the specified commit to the clipboard

Copy Stash Commit URL

This custom action copies the URL of the currently selected commit to the system clipboard, allowing you to paste the URL into an email, a ticket description, or some other place.

Open Stash Commit URL

This custom action opens the currently selected commit in your system's default web browser.

Open Project on Stash

This custom action opens the currently selected project in your system's default web browser.

Limitations

The custom actions currently have the following limitations:

  • They only work for remotes called origin.
  • For remote URLs containing the user name in the URL (e.g. http://first.last@server/...), the Windows start command will fail opening the URL in the browser.
  • Error handling is only rudimentary. In case of an error in the Copy Stash Commit URL command, the error message is copied to the system clipboard.
  • No automated installation script

Installation

The first step is to clone this repo to your local machine, then follow the instructions per operating system.

Mac OS X

There's no automated way to install these in SourceTree, since the SourceTree configuration for the custom actions is kept in ~/Library/Application Support/SourceTree/actions.plist.

To install the custom actions manually, open the SourceTree preferences (SourceTree > Preferences) and switch to the Custom Actions tab. There, add the following custom commands:

  • Copy Stash Commit URL:
    • Menu Caption: "Copy Stash Commit URL"
    • Script to run: Point it to the Stash/copy_commit_url_osx.sh script from this repo
    • Parameters: "$SHA"
  • Open Stash Commit URL:
    • Menu Caption: "Open Stash Commit URL"
    • Script to run: Point it to the Stash/open_commit_on_stash_osx.sh script from this repo
    • Parameters: "$SHA"
  • Open Project on Stash:
    • Menu Caption: "Open Project on Stash"
    • Script to run: Point it to the Stash/open_project_on_stash_osx.sh script from this repo
    • Parameters: (leave empty)

Windows

There's no automated way to install these in SourceTree, since the SourceTree configuration for the custom actions is kept in %localappdata%\Atlassian\SourceTree\customactions.xml (tested with SourceTree 3.1.2).

To install the custom actions manually, open the SourceTree options (Tools > Options) and switch to the Custom Actions tab. There, add the following custom commands:

  • Copy Stash Commit URL:
    • Menu Caption: "Copy Stash Commit URL"
    • Script to run: Point it to the Stash\copy_commit_url_windows.bat script from this repo
    • Parameters: "$SHA"
  • Open Stash Commit URL:
    • Menu Caption: "Open Stash Commit URL"
    • Script to run: Point it to the Stash\open_commit_on_stash_windows.bat script from this repo
    • Parameters: "$SHA"
  • Open Project on Stash:
    • Menu Caption: "Open Project on Stash"
    • Script to run: Point it to the Stash\open_project_on_stash_windows.bat script from this repo
    • Parameters: (leave empty)

Usage

SourceTree is smart enough to show the appropriate custom actions based on the currently selected context and the expected parameters for the custom action. A custom action that has the $SHA parameter appears when clicking on a commit in the SourceTree UI, etc.

To use these custom actions after installation, simply select a commit in a project hosted on Stash, right-click on the commit, then open the Custom Actions item from the context menu and select one of the custom actions.

The Open Project on Stash is not a commit/hash-based action. A commit's context menu still allows to run this custom action from the Custom Actions > Repository Actions context menu (Mac OS X only). On Windows, the repository-based actions can be found in the Custom Actions context menu, below the separator.

The custom actions are also available from the Actions > Custom Actions menu.

Additional Information

For more information on SourceTree's support for custom actions, please refer to the following:

To Do

  • Unit tests

Contributing

Contributions are always welcome. Simply fork this repo, hack away and create a pull request. The examples in the Stash subdirectory give a good overview of how to handle the Stash URLs.

LICENSE

This project is licensed under the terms of the MIT license.

About

Custom Actions for working with Stash from SourceTree

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •