sublime_merge
sublime_merge copied to clipboard
Custom commands fail to run git alias "start" commands 90% of the time
Version info
- OS: Windows 10
- Build: 3211
- Browser: Google Chrome Version 89.0.4389.90 (Official Build) (64-bit)
- git: version 2.31.0.windows.1
Description
When SublimeMerge runs a custom command, which runs a git alias, which tries to use "start" to open some URL in the default browser, it fails to open anything 90% of the time. (but occasionally does successfully open it)
I've been unable to figure out any particular condition that causes it to work or not. Generally clicking around in the browser, opening new tabs etc before running the command in SublimeMerge seems to help it work.
The alias works perfectly running git from the command line. (and I have configured SublimeMerge to use the same git binary as the commandline)
I'd imagine custom commands which open an URL (to a pull request, to an issue tracker, etc) to be quite a common need, e.g. https://forum.sublimetext.com/t/github-gitlab-bitbucket-integration-commands-menu-items/53893
Steps to reproduce
git config alias.test "!start http://google.com"
add to Default.sublime-commands in %APP_DATA%\Sublime Merge\Packages\User:
[
{
"caption": "Open google.com",
"command": "git",
"args": {"argv": ["test"]}
}
]
Expected behavior
The URL opens in the default browser, as it does when running the alias from the commandline.
To work around this: explorer can be used in place of start, and works fine in some cases (depending on your URL; start and explorer behave slightly differently).
Hi @howeaj,
I'm investigating this further, but this seems to be a race condition due to the way the start command is implemented.
It looks as if the start command creates a separate process in parallel to the main process, and does not wait to complete.
You can see this by changing the command to !start http://google.com && sleep 1, which will cause the parent process to stay alive along enough for the child process to complete.
For me it's saying "start: command not found":
I have the following in my .git/config:
[alias] lab = "!start https://gitlab.com/path/to/repo/-/merge_requests/new?merge_request%5Bsource_branch%5D=\"$(git rev-parse --abbrev-ref HEAD)\""
and the following in Default.sublime-commands:
[ { "caption": "Create Merge Request", "command": "git", "args": {"argv": ["lab"]} }, ]