shumphrey / fugitive-gitlab.vim Goto Github PK
View Code? Open in Web Editor NEWA vim extension to fugitive.vim for GitLab support
License: MIT License
A vim extension to fugitive.vim for GitLab support
License: MIT License
I get this error running: Gbrowse
fugitive: Instaweb failed to start and 'origin' is not a supported remote
I added to my .vimrc
let g:fugitive_gitlab_domains = ['https://ourdomain.com']
I have managed in the end to make omnicompletion to work. I have added g:gitlab_api_keys
variable:
let g:fugitive_gitlab_domains = [
\ 'https://gitlab.com',
\ 'https://gitlab.internal.site.com'
\ ]
let g:gitlab_api_keys = {'gitlab.com': 'somethingverysecret'}
Then I had to discover that appropriate remote
for git must be origin
(that's a pity, I usually use upstream
as a name of my remote; but I can survive).
In other IDEs (VSCode and WebStorm), opening in GitLab will not just open the current file, but also will open it to the same line your cursor is on. It would be nice to have this in GBrowse
too
Great plugin by the way!
Continuing from tpope/vim-fugitive#1147, I've found out that fugitive-gitlab.vim causes the error. To quote:
Error detected while processing function <SNR>150_config[4]..<SNR>177_buffer_repo:
line 1:
E605: Exception not caught: fugitive: Removed in favor of fugitive#repo()
Error detected while processing function FugitiveDetect:
line 11:
E171: Missing :endif
It would be much convenient to avoid to open browser to see the reviewers commentaries for MRs.
Docs: https://docs.gitlab.com/ee/api/discussions.html
Kind regards,
Alex.
Self hosted gitlab often has quirks such as ssh url being different to web url.
This is solvable with git/ssh settings but needs documenting.
An FAQ would help document this.
I would think that there are now so many gitlab repos on https://gitlab.com that it would make sense to default to it, so that the beginner user wouldn't have to bother with setting g:fugitive_gitlab_domains
.
When I do :GBrowse
(in a file where I can see git blame properly) I get:
fugitive: no GBrowse handler installed for 'ssh://[email protected]_name.cntry:12112/project_name/repo_name.git'
My configuration(using neovim and lua, but no syntax errors) is:
vim.g.fugitive_gitlab_domains = { ['ssh://[email protected]:12112'] = 'https://gitlab.company_name.cntry:3344' }
vim.g.gitlab_api_keys = { ['https://gitlab.company_name.cntry:3344'] = 'newly_generated_access_key' }
Is it so that the GitLab domains are supposed to contain the project and repo names as well?
Our gitlab is hosted at https://example.com/gitlab
but the remote is [email protected]
. :Gbrowse
results in fugitive: "origin' is not a supported remote
I version control my .vimrc publicly, so if possible I'd to read the access token from a command or file. Is this possible somehow?
When I open a file with :Gbrowse
it goes to https://gitlab.com/baardbaard/my-project/baardbaard/my-project/blob/etc. Any idea what could be the problem?
Thanks!
My company is self-hosting gitlab. The url on the website to a particular file is
https://[domain]/cat_projects/frida/blob/master/fridapoc.py
but :GBrowse!
prints
https://[domain]/cat_projects/frida/-/blob/master/fridapoc.py
, notice the extra -
.
I thought maybe it's because of the different address for ssh
connections, so I tried setting:
let g:fugitive_gitlab_domains = {'ssh://[domain]:[port]/': 'https://[domain]/'}
but then I get an error:
fugitive: no GBrowse handler installed for 'ssh://git@[domain]:[port]/cat_projects/frida.git'
Do you have any idea what could be the issue?
Last week Gitlab changed slightly path to commit links:
I thought that it was bug, but looks like changes will stay.
UPDATE: Relevant issue: https://gitlab.com/gitlab-org/gitlab/-/issues/28848#release-notes
my vimrc looks like this
Plug 'tpope/vim-fugitive'
Plug 'shumphrey/fugitive-gitlab.vim'
let g:fugitive_gitlab_domains = ['https://gitlab-myserver.private.org']
let g:gitlab_api_keys = {'gitlab-myserver.private.org': 'my-access-token'}
and whenever I run :Gbrowse
, vim responds with:
fugitive: 'origin' is not a supported remote
Is this a bug or something wrong with my config? Thank you!
I found g:fugitive_gitlab_ssh_user
from the code when looking for a way to support our private gitlab . That setting is currently undocumented. I guess you don't want to do so because the current implementation is not satisfied: It can't support multiple gitlab ssh users for different domains.
Perhaps we can deprecate all 3 variables:
fugitive_gitlab_domains
gitlab_api_keys
fugitive_gitlab_ssh_user
And introduce a new array of objects: fugitive_gitlab_configs
:
let g:fugitive_gitlab_configs = [{
'api_key': '...',
'domain': '...',
'ssh_user': '...'
}]
Using that construction, we can have more customization per domains in future if needed. How do you think?
The plugin is not working for me. I have tracked the problem down to the regex here. The problem is that my GitLab ssh user is gitlab
not git
. I know this is not standard and probably means that I set up GitLab incorrectly, but do you think it would be possible to update the regex? I have confirmed that changing it to ...\|git\%(lab\)\?@\|ssh://git\%(lab\)\?\|...
works.
I am also running ssh on a port other than 22. Maybe it is possible to add let base = substitute(base, ':\d\{1,4}\/', '/', '')
to strip the port before let base = tr(base, ':', '/')
?
Sometimes, I need a url to track the latest status of file, this could be accomplished via branch name in the url. Thanks!
Do you have any interest in adding commands that lint the CI file or return a merged one? I created some commands for my own vimrc that do this. I could clean them up and I could add them to the repo.
https://docs.gitlab.com/ee/api/lint.html
let g:fugitive_gitlab_domains = ['https://gitlab.com']
let g:gitlab_api_keys = {'gitlab.com': 'xxxxxxxxxxxxxxxxxxxx'}
function! CiLint()
echo system("jq --null-input --arg yaml \"$(<".bufname().")\" --arg branch $(git branch --show-current) '.content=$yaml|.ref=$branch' | curl --header \"Content-Type: application/json\" --header \"PRIVATE-TOKEN: ".g:gitlab_api_keys['gitlab.com']."\" \"https://cee-gitlab.com/api/v4/ci/lint\" --data @- -s | jq '.errors'")
endfunction
function! CiMerge()
execute("%!jq --null-input --arg yaml \"$(<".bufname().")\" --arg branch $(git branch --show-current) '.content=$yaml|.ref=$branch|.include_merged_yaml=true' | curl --header \"Content-Type: application/json\" --header \"PRIVATE-TOKEN: ".g:gitlab_api_keys['gitlab.com']."\" \"https://cee-gitlab.com/api/v4/ci/lint\" --data @- -s |jq -r '.merged_yaml' ")
endfunction
command! CiLint call CiLint()
command! CiMerge call CiMerge()
I want to use this plug in by loading it using vim-plug
. All other plugins have no problem being cloned and downloaded automatically, but with fugitive-gitlab.vim
, vim-plug
all of a sudden wants me to type in my Github username and password as if I was doing an http(s) clone. It seems like it can't read my ssh data for some reason.
This doesn't happen with any other plugin, so I thought it is wasn't a vim-plug
issue.
Any ideas?
It would be nice to support gitlab snippets.
The latest commits added the possibility to auto-complete issues and usernames by curl
ing the GitLab API. This requires getting a Personal Access Token and adding it to your vimrc.
Since the user is using GitLab repositories, there might be cached credentials already. There could be a way to fetch these credentials directly if there are nothing configured in the vimrc.
Docs: https://git-scm.com/docs/gitcredentials
My POC:
$ git credential fill <<<url=$REMOTE_URL
protocol=https
host=$HOSTNAME
username=$UNAME
password=$PASSWORD
If the user has some caching configured, this information is available. Otherwise there should be a prompt for the username and password.
I am using neovim.
I have fugitive, and fugitive-gitlab both installed.
Lazy.nvim seems to install both successfully. I know this because I've used Fugitive for a while.
I have the following function:
function ConfigGitlab()
vim.g.fugitive_gitlab_domains['ssh://[email protected]:121112'] = 'https://gitlab.company.com:3344'
end
But when I call this, I get:
Error detected while processing /Users/v4g4x/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /Users/v4g4x/.config/nvim/lua/core/gitlab.lua:3: attempt to index field 'fugitive_gitlab_domains' (a nil value)
Clearly, I'm not converting the vim option from Vimscript to Lua correctly.
Any help on how this may be done?
I know that :help license
is referenced, but still - for the re-packaging to
Linux distributions - it is a good idea to provide a copy of the license file.
At least I, as Fedora packager, am sort of pushed to at least try to
request this:
https://docs.fedoraproject.org/en-US/packaging-guidelines/LicensingGuidelines/#_license_text
Is it possible to open the link with anchors at gitlab?
For example,
http://demo.mygitlab.com/a/b/c#L20
and
Upgraded and it doesn't work (opens empty browser). Maybe this commit is a problem (not sure just guessing).
Do you plan to add completion of users, collaborators etc as in https://github.com/tpope/vim-rhubarb? Thank you!
I'm going to take away fugitive#GitVersion()
because when it comes to checking version numbers with a regex everybody loses. FugitiveRemoteUrl()
provides a much cleaner solution. You can also use it to clean up those fugitive#repo().config()
calls (which is probably going away too eventually).
It only seems to work for the master branch.
If you have multiple accounts on a server, one way to disambiguate between repositories is to include the username in the URL.
This makes :Gbrowse
fail.
$ git remote -v
gitlab https://gitlab.com/somini/dotnvim.git
$ git remote -v
gitlab https://[email protected]/somini/dotnvim.git
I confirmed the same behaviour on a hosted instance, i.e. not gitlab.com.
The easy way to solve this is by stripping everything to the left of the @
, but I couldn't find the exact location at a glance.
I'm getting the following error with latest fugitive version:
E117: Unknown function: fugitive#git_version
Error detected while processing function gitlab#omnifunc[48]..gitlab#issues[1]..<SNR>280_gitlab_project_from_repo:
line 10:
E15: Invalid expression: fugitive#git_version() =~# '^[01]\.\|^2\.[0-6]\.'
Apologies if my terminology is a little off here, and I'm also new to gitlab, so this might not be a "general" issue.
We have github repositories merged into gitlab, and after the migration process have updated the git remote to point at gitlab instead. All of which is to say that could be the reason for this issue.
The :GBrowse
command is working correctly from file views, but not from commit views
:GBrowse
and the file opens up correctly in Gitlab ๐ (e.g. https://gitlab.com/MY_ORG/MY_SUBGROUP/MY_PROJECT/blob/80d4ad4c4480753588ab87533ecb4b2a3299a5b9/FILE_NAME):Git blame
, pick any line in the blame, and hit returntree
and parent
lines at the top etc....:GBrowse
and the Gitlab opens up with a 404 ๐ (e.g. https://gitlab.com/MY_ORG/MY_SUBGROUP/MY_PROJECT/commit/56f016eb16ff32911c2a76825acfc7093cc48e62)Just manually add /-
after MY_PROJECT seems to produce the correct URL structure (e.g. https://gitlab.com/MY_ORG/MY_SUBGROUP/MY_PROJECT/-/commit/56f016eb16ff32911c2a76825acfc7093cc48e62)
Hey first of all thank you for your hard work with this plug in!
I noticed that it seems to work quite well with casual GBrowse
ing and so without providing any credentials but as soon as I supply a let g:gitlab_api_keys = {'gitlab.com': 'glPATgoeshere'}
I can noticeably see my typing lag in a git commit message window. Is this something you can replicate on your end? Having direct issues integration is a super cool feature for the work flow but it seems to create this weird side affect of prohibitively slow typing.
I have included a gif of this behaviour below. For what it's worth I experience the same issue with Rhubarb. Perhaps it's a curl thing or something on my end. In either case would be very happy to hear back and help address what may be going on.
cheers!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.