Skip to content

-ls not working #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
avegancafe opened this issue Apr 9, 2015 · 14 comments
Closed

-ls not working #183

avegancafe opened this issue Apr 9, 2015 · 14 comments

Comments

@avegancafe
Copy link

So I'm having this issue where :Gist -ls isn't working at all (It just prints "Not Found"). I have 1 starred gist, so there's definitely at least one, but even so, it would be nice if it said like "No starred Gists" or something instead of "Not Found", since it also says that if the url is broken, which was confusing.

@mattn
Copy link
Owner

mattn commented Apr 9, 2015

Do you have ~/.gist-vim that contains github token? (note: please don't paste it at here)

@avegancafe
Copy link
Author

Yes, I have a key. I can also do many of the other things described in the gist-vim README.

@mattn
Copy link
Owner

mattn commented Apr 10, 2015

Could you please try following? (please note that don't paste private contents)

apply patch following

diff --git a/autoload/gist.vim b/autoload/gist.vim
index 0cd0c97..032367c 100644
--- a/autoload/gist.vim
+++ b/autoload/gist.vim
@@ -190,6 +190,7 @@ function! s:GistList(gistls, page) abort
     echohl ErrorMsg | echomsg 'Gists not found' | echohl None
     return
   endif
+  let g:debug = res
   let content = webapi#json#decode(res.content)
   if type(content) == 4 && has_key(content, 'message') && len(content.message)
     bw!

:Gist -ls

:echo g:debug

@avegancafe
Copy link
Author

{'status': '404', 'header': ['Server: GitHub.com', 'Date: Fri, 10 Apr 2015 00:39:08
 GMT', 'Content-Type: application/json; charset=utf-8', 'Content-Length: 87', 'Stat
us: 404 Not Found', 'X-RateLimit-Limit: 5000', 'X-RateLimit-Remaining: 4999', 'X-Ra
teLimit-Reset: 1428629948', 'X-OAuth-Scopes: gist', 'X-Accepted-OAuth-Scopes: repo'
, 'X-GitHub-Media-Type: github.v3', 'X-XSS-Protection: 1; mode=block', 'X-Frame-Opt
ions: deny', 'Content-Security-Policy: default-src ''none''', 'Access-Control-Allow
-Credentials: true', 'Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-Ra
teLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted
-OAuth-Scopes, X-Poll-Interval', 'Access-Control-Allow-Origin: *', 'X-GitHub-Reques
t-Id: 9B2977EE:1B15:364684:55271BAC', 'Strict-Transport-Security: max-age=31536000;
 includeSubdomains; preload', 'X-Content-Type-Options: nosniff'], 'message': 'Not F
ound', 'content': '{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}
'}

Looks like the url is invalid

@mattn
Copy link
Owner

mattn commented Apr 10, 2015

What is gist_api_url?

:Gist -ls
:echo gist_api_url

should be printed as https://api.github.com/

@avegancafe
Copy link
Author

That is indeed the url that is printed

@mattn
Copy link
Owner

mattn commented Apr 10, 2015

Hmm, could you please remove ~/.gist-vim or rename it at once?

@avegancafe
Copy link
Author

Yeah I tried doing that a couple times, didn't help

@mattn
Copy link
Owner

mattn commented Apr 10, 2015

Did you input password for authentication?

@avegancafe
Copy link
Author

Yup

@fvictorio
Copy link

fvictorio commented Aug 3, 2018

Hi, I know that this is an old issue, but just in case: I fixed this by adding let g:gist_show_privates = 1 to my .vimrc.

I don't know if this is a bug or not. I noticed that the used URL ended up being https://api.github.com/users/starred/gists (which as far as I can tell is not valid) and then in this part of the code:

  if a:gistls ==# '-all'
    let url = g:gist_api_url.'gists/public'
  elseif get(g:, 'gist_show_privates', 0) && a:gistls ==# 'starred'
    let url = g:gist_api_url.'gists/starred'
  elseif get(g:, 'gist_show_privates') && a:gistls ==# 'mine'
    let url = g:gist_api_url.'gists'
  else
    let url = g:gist_api_url.'users/'.a:gistls.'/gists'
  endif

it seems like the else branch ends up being used and so the resulting URL is the one I mentioned.

Hope this helps!

@avegancafe
Copy link
Author

avegancafe commented Aug 15, 2018

That fix worked for me @fvictorio ! I actually just checked out mine, and it looks like it's going to this:

https://api.github.com/users/kylelholzinger@gmail.com/gists

instead of this:

https://api.github.com/users/kyleholzinger/gists

Going to look into opening up a PR to fix this

@avegancafe
Copy link
Author

update @fvictorio: I nailed down that on line 801 it sets gistls to g:github_user, which will default to the output of the command gith config --get github.user. In my case it was my email, but I changed it to my username and now it's working. Probably should be something in the readme? Not sure

@mattn
Copy link
Owner

mattn commented Aug 17, 2018

Already noted in README.

$ git config --global github.user Username

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants