Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Import default username from 'git config github.user' #64

Merged
merged 3 commits into from Jan 22, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions autoload/gista/client.vim
Expand Up @@ -109,6 +109,10 @@ function! s:get_default_username(apiname) abort
let default = get(g:gista#client#default_username, '_', '')
let username = get(g:gista#client#default_username, a:apiname, default)
endif
if empty(username)
let username = system('git config github.user')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please define s:R = s:V.import('Process') at the top of this file and use s:R.system() instead.

Additionally, please add a switch variable (say, g:gista#client#use_git_config_github_user) at the bottom of this file (the default value should be 0) and use it to check if gista should call git config github.user.
It is required because

  1. Calling system would slow the response
  2. Some users may want to use vim-gista as an anonymous mode in default. This part is called when a new client is created, mean that it will be called by any :Gista XXX command so without switch option. That's why users require to call :Gista logout everytime after vim started if they want to use vim-gista as an anonymous mode in default.

And please add documentation about the variable around

https://github.com/lambdalisue/vim-gista/blob/master/doc/vim-gista.txt#L124
https://github.com/lambdalisue/vim-gista/blob/master/doc/vim-gista.txt#L256
https://github.com/lambdalisue/vim-gista/blob/master/doc/vim-gista.txt#L471

let username = substitute(username, '\([^\r\n]\+\).*', '\1', '')
endif
if empty(username)
return ''
endif
Expand Down