TL;DR: SourceTree for Windows recently added the "commit text links" feature, but it appears that the replacements must be set up per-repository. Is there a way to apply them globally or a config file that could be modified programmatically to set them?
Long version: The "commit text links" feature looks incredibly useful but I have a bit of a problem: We have about a dozen JIRA projects and over 25 repositories that each of them could be related to (none of them are 1-to-1 mappings). While I could set up a single regular expression to match each of the JIRA projects, it's a bit much to ask all of my developers to set it up through the UI for each and every repository. To really take advantage of this I ideally need to be able to give them instructions on a single file to modify or I need to generate a setup script that I can distribute to our developers.
Is there a config file that this setting is saved in? I was expecting to see it in something like .hg/hgrc but I couldn't find anything. I also couldn't find any relevant settings in the SourceTree Program Files folder.
Alternatively, is there a global or default setting that can be applied across all repositories? That plus the regex version could make setup significantly less painful if still manual.
Thanks!
(Note: I'm in version 1.3.3.0 of SourceTree for Windows, which I believe is the most recent stable version)
May be a bit late, but I've found a relatively easy way to do this.
Underneath your .hg/.git folder within your repository should exist a file called 'sourcetreeconfig.' This is where the links live and can be manually edited.
First make sure that you have closed all of the existing repository tabs within sourcetree, and additionally close sourcetree afterwards. Then, (assuming you have already configured a repository) copy the block from the respective repository's sourcetreeconfig and do a replace across all of your sourcetreeconfig files. This would be if you have multiple tied to the same project. It should be relatively easy to throw something together that can configure for different projects, just replace the url/project within the config.
Upon reopening sourcetree, each of your repositories should reflect this change.
This was performed using version 1.6.5.0 of sourcetree.
Here in late 2019, the ability to globally configure commit text links in Sourcetree 3.2.6 for Windows still does not exist. Since this question was one of the few hits with a decent answer, I figured I would add an automated solution to the answers. I'm not a programmer, and I know the RegEx isn't the best, but this simple PowerShell script I cobbled together gets the job done. Make sure Sourcetree is closed before you run the script.
sourcelinker
script into a Notepad++ or similar text editor application."CommitTextLinks": [
through the closing bracket and comma ],
. For example:"CommitTextLinks": [
{
"$id": "11",
"LinkType": 99,
"Regex": "[fF][bB][#\\s]*(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[fF][bB][#\\s]*(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
}
],
sourcelinker
script between the single quotes that follow $New1 =
. sourcelinker.ps1
.sourcelinker.ps1
to the root folder where your Git repos reside.This script example contains Regex examples that link to Fogbugz and handles variations such as:
# Sourcelinker script
$InputFiles = Get-Item ".\*\.git\sourcetreeconfig.json"
$Old1 = '"CommitTextLinks": null,'
$New1 = '"CommitTextLinks": [
{
"$id": "9",
"LinkType": 99,
"Regex": "[bB][Uu][gG][sSzZ]\\s*[Ii][Dd]s?\\s*[#:; ]+(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[bB][Uu][gG][sSzZ]\\s*[Ii][Dd]s?\\s*[#:; ]+(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
},
{
"$id": "10",
"LinkType": 99,
"Regex": "[cC][aA][Ss][Ee]+\\s*(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[cC][aA][Ss][Ee]+\\s*(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
},
{
"$id": "11",
"LinkType": 99,
"Regex": "[fF][bB][#\\s]*(\\d+)",
"LinkToUrl": "https://companyname.fogbugz.com/f/cases/$1",
"Project": null,
"RootUrl": null,
"Description": "[fF][bB][#\\s]*(\\d+) => https://companyname.fogbugz.com/f/cases/$1"
}
],'
$InputFiles | ForEach {
(Get-Content -Path $_.FullName).Replace($Old1,$New1) | Set-Content -Path $_.Fullname
}
Solution inspired thanks to suggestion by Andrew Pearce from this thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With