Skip to content
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

Improve handling of default env vars vs command line switches -- better messages, etc #12

Open
BretFisher opened this issue Jan 31, 2013 · 9 comments

Comments

@BretFisher
Copy link
Contributor

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.

Screenshot_1_31_13_11_25_AM-2

@Iristyle
Copy link
Owner

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.

@BretFisher
Copy link
Contributor Author

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?

@Iristyle
Copy link
Owner

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.

@Iristyle
Copy link
Owner

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.

@BretFisher
Copy link
Contributor Author

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.

@Iristyle
Copy link
Owner

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 😸

Thanks for trying it out, and PRs are welcome if you run into anything else.

@Iristyle
Copy link
Owner

I'm going to leave this issue open as a reminder to fix validation / add inline docs.

@BretFisher
Copy link
Contributor Author

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.

@BretFisher
Copy link
Contributor Author

actually if I remove the array syntax from $matches[1] it works with $matches but not sure that is your intention.

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

2 participants