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

fix: be more helpful on bad args #1

Merged
merged 1 commit into from
Apr 21, 2020

Conversation

alexeldeib
Copy link
Contributor

@alexeldeib alexeldeib commented Apr 16, 2020

If you manually pass an empty string ("") for either argument, main will panic. I found this out because shellcheck likes double quotes around variables and I ran apidiff with an empty variable.

Before:

ace@ace-home-vm:~/go/src/github.com/joelanford/go-apidiff$ ../apidiff ""
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x96b2bd]

ace@ace-home-vm:~/go/src/github.com/joelanford/go-apidiff$ ../apidiff "HEAD" ""
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x96b2bd]

After:

ace@ace-home-vm:~/go/src/github.com/joelanford/go-apidiff$ ../apidiff ""
Error: oldCommit should not be empty
Usage:
  go-apidiff <oldCommit> [newCommit] [flags]
...

ace@ace-home-vm:~/go/src/github.com/joelanford/go-apidiff$ ../apidiff "HEAD" ""
Error: if provided, newCommit should not be empty
Usage:
  go-apidiff <oldCommit> [newCommit] [flags]
...

@alexeldeib
Copy link
Contributor Author

btw, awesome tool

Copy link
Owner

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks!

@joelanford joelanford merged commit 7ccff33 into joelanford:master Apr 21, 2020
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

Successfully merging this pull request may close these issues.

None yet

2 participants