Lazygit: Configurable Pull request URL

Created on 7 Nov 2018  路  9Comments  路  Source: jesseduffield/lazygit

Describe the solution you'd like
I've started experimenting with this awesome tool at work, and it's going great! One thing however I've noticed is that I cannot use the pull request feature.

I'm using it in a closed off network, with a custom gitlab setup, so of course the built in gitlab url doesn't appear, nor would it help if it did.

It would be awesome if the config could accept some "name: url:" parameters for custom pull request links.

Thanks again for the project. I love the simplicity and usability!

All 9 comments

Yes this is an issue I have as well! Having this configurable from config.yml would be very useful!

I would like it as well!

we could also maybe detect what kind of server we are dealing with on the fly:

  • For github, gitlab, bitbucket we can detect it by the url
  • For selfhosted gitlab check: https://server.url/api/v4 and https://server.url/api/v4/version
  • For gitea and gogs check: https://server.url/api/v1/version

@mjarkk that sounds good to me. Are there any cases where we wouldn't be able to derive the url from the repo itself? If there are, then we'll need to add support for per-repo urls in the config.

ya there are some caveats to this, this won't work if:

  • The git server has a different domain name for git over ssh
  • The API for the git server is implemented under a different domain name like the public gitlab (this is also fixable by just looking at the response html data for the non api routes)

But for those cases we can show a popup with a list of the git servers we support.
And i don't think there are so meany server who fall in that section.

  • The git server has a different domain name for git over ssh

My case exactly. So to solve that, I came up with this change. The config.yml file looks like this:

services:
  "gitlab.<myWorkDomain>": "https://gitlab.<myWorkDomain>/%s/%s/merge_requests/new?merge_request[source_branch]=%s"
  "git.<myWorkDomain>": "https://gitlab.<myworkDomain>/%s/%s/merge_requests/new?merge_request[source_branch]=%s"

That's definitely not the best way as it exposes the format string, which can lead to awfully wrong URLs, and also tightly couples the config string . So, some sort of refactoring is needed, e.g. create a ServiceType with a domain-variable format string, and then use those on the Service (fixed and user-added) by just pointing the type.

Here's the refactored option, which allows this kind of configuration:

services:
  "gitlab.<myWorkDomain>": "gitlab:gitlab.<myWorkDomain>"
  "git.<myWorkDomain>": "gitlab:gitlab.<myWorkDomain>"

Nice! No more gory details on the configuration 馃槃

P.S.: Also I've fixed the getRepoInfoFromURL function. as GitLab allows grouping, e.g. team/group-of-projects/project1. Let me know if I should cherry-pick that into a separate PR.

@wwmoraes did you submit a merge request for this?

@craftyguy no I didn鈥檛 as I diverged my attention on other matters. I鈥檒l pick it up in the morning, do some rebasing and submit 馃殌

Sent with GitHawk

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cbeley picture cbeley  路  6Comments

pshirshov picture pshirshov  路  3Comments

matthiasroos picture matthiasroos  路  3Comments

5minpause picture 5minpause  路  6Comments

stratosgear picture stratosgear  路  5Comments