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
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions autoload/gista/client.vim
Expand Up @@ -5,6 +5,7 @@ let s:V = gista#vital()
let s:C = s:V.import('System.Cache')
let s:P = s:V.import('System.Filepath')
let s:G = s:V.import('Web.API.GitHub')
let s:R = s:V.import('Process')

let s:registry = {}
let s:current_client = {}
Expand Down Expand Up @@ -109,6 +110,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 g:gista#client#use_git_config_github_user && empty(username)
let username = s:R.system('git config github.user')
let username = substitute(username, '\([^\r\n]\+\).*', '\1', '')
endif
if empty(username)
return ''
endif
Expand Down Expand Up @@ -357,6 +362,7 @@ call gista#define_variables('client', {
\ 'cache_dir': '~/.cache/vim-gista',
\ 'default_apiname': 'GitHub',
\ 'default_username': '',
\ 'use_git_config_github_user': 1,
\})

let &cpo = s:save_cpo
Expand Down
8 changes: 8 additions & 0 deletions doc/vim-gista.txt
Expand Up @@ -473,6 +473,14 @@ g:gista#client#default_username *g:gista#client#default_username*
A default username used in |:Gista-login| command.
Default is ''.

*g:gista#client#use_git_config_github_user*
g:gista#client#use_git_config_github_user

1 to read user's gitconfig.
This executes "git config github.user" command
and read username from the output.
Default is 1.

*g:gista#command#json#default_opener*
*g:gista#command#open#default_opener*
*g:gista#command#list#default_opener*
Expand Down