Posh-GitHub
Posh-GitHub copied to clipboard
Improve handling of default env vars vs command line switches -- better messages, etc
Was thinking I was going to have to write my own tool to check github repos from PowerShell, but found yours. I've tried it on Server 2012, Win8, and now Win7 (with Posh 3.0) and get the same errors every time. Wondered if I was doing it wrong or what.
After getting token, and running Get-GitHubRepositories I get "unexpected error occurred" at line 1 char 1.
Thanks for any help or suggestions.
That is ... odd.
It does need some love in the docs dept, and a few other commands that are missing based on my daily workflow, but I'm using the module just about every day. A couple of co-workers are using it as well.
Out of curiosity, have you closed your session then reopened after setting the token? Maybe I have a bug in storing the environment variable properly after initial creation.
I see GITHUB_OAUTH_TOKEN in "dir env:" but restarted console session anyway. I'm assuming the only variable I must have set is oauth?
A couple of other tips to figure out what might be going on...
- Use the
-Verbose
switch to see if you get additional output from Powershell as that stack isn't too helpful. - Use something like Resolve-Error against the global
$Error
object to see if you can grab a more detailed stack trace.
I was almost going to say it could be a git line ending issue, if you happened to clone locally with LF
endings (based on the core.autocrlf
and a few other git settings)... but if creation of the token has succeeded, it can't be an unreadable source file I wouldn't think.
Yes, GITHUB_OAUTH_TOKEN
is the only mandatory setting for all commands. However, others do depend on the user name being present. So it could just be poor validation code here.
Try setting your username and org with the Set-GitHubUserName
and Set-GitHubOrganization
heleprs.
Great tips, thanks. I'll set user/org and also learn those debug options, and see what is tripping it up. BTW Get-GitHubIssues works, but none of the other Get's (Teams, Events, Repos) work.
Yeah.. I think I set them up to read the env var if it the command line switch isn't passed.
Hopefully soon I'll get a chance to take a pass through and improve the docs / arg validation. I'm using built-in PS validation, but when a value isn't passed and the environment variable isn't set, I'm likely not dropping nice user messages.
Definite room for improvement -- this was hacked together pretty quickly :smile_cat:
Thanks for trying it out, and PRs are welcome if you run into anything else.
I'm going to leave this issue open as a reminder to fix validation / add inline docs.
it looks like on line 573, for piping your -match to $matches[1]
, when there is no match in $response.Headers.Link
it throws an error cannot index into a null array. I'm assuming this if for pagination of results but I'm not sure how to first check for null inline before passing to foreach $matches
.
actually if I remove the array syntax from $matches[1]
it works with $matches
but not sure that is your intention.