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

--commits option does not handle 0 commits case. #22

Closed
tommyip opened this issue Mar 13, 2017 · 2 comments · Fixed by #25
Closed

--commits option does not handle 0 commits case. #22

tommyip opened this issue Mar 13, 2017 · 2 comments · Fixed by #25
Labels
bug User-facing bugs

Comments

@tommyip
Copy link
Contributor

tommyip commented Mar 13, 2017

Command

$ gitlint --commits upstream/master...HEAD

where upstream/master and HEAD is the same commit.

Error

...
...
File "/home/tommy/Documents/gitlint/gitlint/cli.py", line 114, in lint
    last_commit = gitcontext.commits[-1]
IndexError: list index out of range

Solution

Either just tell the user there is no commit in the range or lint the HEAD commit. I prefer the second option but some user might find that inconsistent with how Git's range work.

@jorisroovers jorisroovers added the bug User-facing bugs label Mar 14, 2017
@jorisroovers
Copy link
Owner

Confirmed. @tommyip were you planning to look into this? If not, I can see if I can make some time later this week. We should probably fix this for the upcoming 0.8.1. release. Also, I'd vote for the first option, just telling the user there is no commit as a check for len(gitcontext.commits) > 0 will capture more use cases in general.

@tommyip
Copy link
Contributor Author

tommyip commented Mar 15, 2017

Yeah I will work on this.

tommyip added a commit to tommyip/gitlint that referenced this issue Mar 15, 2017
This fixes a "index out of range" exception when the specified git
range for --commits is empty.

Fixes jorisroovers#22.
jorisroovers pushed a commit that referenced this issue Mar 16, 2017
This fixes a "index out of range" exception when the specified git
range for --commits is empty.

Fixes #22.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug User-facing bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants