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

lab clone without url causes panic instead of printing help #11

Closed
hasLeland opened this issue Sep 11, 2017 · 3 comments
Closed

lab clone without url causes panic instead of printing help #11

hasLeland opened this issue Sep 11, 2017 · 3 comments

Comments

@hasLeland
Copy link

hasLeland commented Sep 11, 2017

What was expected?

When running git clone without specifying a url, I get a help message:

$ git clone
You must specify a repository to clone.

usage: git clone [<options>] [--] <repo> [<dir>]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
...
...

What happened instead?

When I ran lab clone without a url, lab panic'd:

$ lab clone
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x58350f]

goroutine 1 [running]:
github.com/zaquestion/lab/vendor/github.com/spf13/cobra.(*Command).ParseFlags(0x9c6a40, 0xc42000c310, 0x1, 0x1, 0x9c6a40, 0x9e69a0)
	/home/leland/projects/go-projects/src/github.com/zaquestion/lab/vendor/github.com/spf13/cobra/command.go:1267 +0x3f
github.com/zaquestion/lab/cmd.Execute()
	/home/leland/projects/go-projects/src/github.com/zaquestion/lab/cmd/root.go:81 +0x122
main.main()
	/home/leland/projects/go-projects/src/github.com/zaquestion/lab/main.go:6 +0x20

How might this be fixed?

From what I can see in the cmd/root.go file, the problem is in an unchecked slice of the os.Args slice on line 81. Directly above that line is a somewhat confusing comment which may or may not have anything to do with this issue, I had a hard time understanding it, though it may be of some use to whoever choses to fix this.

The change would be to check if clone has been provided without any additional arguments/parameters, and if it has, to print a help message in some way. The printing of a help message could be done by dropping down to gits help message or by printing labs own custom help message.

@zaquestion
Copy link
Owner

@hasLeland Thanks for reporting! I've put in a fix. This issue still needs tests to close.

zaquestion added a commit that referenced this issue Sep 14, 2017
[#11] (clone) fixes panic on no arguments
bmess added a commit to bmess/lab that referenced this issue Oct 14, 2017
I think using the Args argument might be cleaner.
bmess added a commit to bmess/lab that referenced this issue Oct 14, 2017
I think using the Args argument might be cleaner.
@bmess
Copy link
Contributor

bmess commented Oct 14, 2017

I apologize for beating a dead horse but I think this might be an elegant solution for an elegant tool 💯

zaquestion added a commit that referenced this issue Oct 19, 2017
…pdates to cobra that might assist with a more idiomatic fix
zaquestion added a commit that referenced this issue Oct 19, 2017
(vendor) Update all vendors, primarily driven by issue #11 and some updates to cobra that might assist with a more idiomatic fix
@bmess
Copy link
Contributor

bmess commented Nov 8, 2017

I believe this is fixed. Tested with 0.5.0. I closed the MR

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

No branches or pull requests

3 participants