Skip to content

Commit 092cb07

Browse files
committed
An Sourcetree custom action for opening an Gitlab merge request window in the Google Chrome browser.
0 parents  commit 092cb07

10 files changed

+110
-0
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
img/ export-ignore
2+
.gitattributes export-ignore
3+
.gitignore export-ignore
4+
LICENSE export-ignore
5+
README.md export-ignore

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 JCID B.V.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Intro
2+
3+
An small tool that will open the Google Chrome browser to create an new Gitlab merge request. The Gitlab merge request is based on the current branch and current opened GIT directory inside Sourcetree.
4+
5+
# Installation
6+
7+
```bash
8+
composer global require jcid/sourcetree-merge-request-opener
9+
```
10+
11+
# Why?
12+
13+
Why was this built? Because Jira has indicated that they will not support Gitlab's own instances. For more information you can read here:
14+
- https://jira.atlassian.com/browse/SRCTREE-1845
15+
16+
# Sourcetree configuration
17+
18+
Open Sourcetree `preferences` (short key: `⌘ ,`)
19+
20+
![Sourcetree preferences](img/sourcetree-preferences.png)
21+
22+
Go to the `Custom Actions`
23+
24+
![Sourcetree custom actions](img/sourcetree-custom-actions.png)
25+
26+
Add an new `Custom Action` with the values
27+
28+
| Option | Value |
29+
|---------------|--------------------------------------------------------------------|
30+
| Menu Caption | `Create Gitlab merge request` |
31+
| Shortcut | ⌘ = |
32+
| Script to run | `/Users/jcid/.composer/vendor/bin/sourcetree-merge-request-opener` |
33+
| | *Replace the `jcid` username for your own username* |
34+
| Parameters | `$REPO` |
35+
36+
![Sourcetree custom action configuration](img/sourcetree-custom-action-configuration.png)
37+
38+
Now you can easily open a Gitlab merge request from the current branch with the set shortcut `⌘ =`

composer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "jcid/sourcetree-merge-request-opener",
3+
"description": "An Sourcetree custom action for opening an Gitlab merge request window in the Google Chrome browser",
4+
"license": "MIT",
5+
"keywords": [
6+
"sourcetree",
7+
"gitlab",
8+
"merge request"
9+
],
10+
"authors": [
11+
{
12+
"name": "Jeffrey Cafferata",
13+
"email": "[email protected]"
14+
}
15+
],
16+
"support": {
17+
"issues": "https://github.com/JCID/sourcetree-custom-action-gitlab-merge-request-opener/issues"
18+
},
19+
"require": {
20+
},
21+
"bin": [
22+
"sourcetree-merge-request-opener"
23+
]
24+
}
43.1 KB
Loading

img/sourcetree-custom-actions.png

38.3 KB
Loading

img/sourcetree-preferences.png

48.5 KB
Loading

img/sourcetree.png

45.9 KB
Loading

sourcetree-merge-request-opener

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/local/bin/php
2+
<?php
3+
4+
require_once 'vendor/autoload.php';
5+
6+
$repoPath = $argv[1];
7+
$iniConfig = parse_ini_file(
8+
sprintf(
9+
'%s/.git/config',
10+
$repoPath
11+
)
12+
);
13+
$repoUrl = $iniConfig['url'];
14+
$repoUrl = str_replace(
15+
[':', 'git@', '.git',],
16+
['/', 'https://', '/'],
17+
$repoUrl
18+
);
19+
20+
$openCommand = sprintf('open "%smerge_requests/new?merge_request[source_branch]="$(git rev-parse --abbrev-ref HEAD) -a "Google Chrome"', $repoUrl);
21+
exec($openCommand);

0 commit comments

Comments
 (0)