-
Notifications
You must be signed in to change notification settings - Fork 301
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
NullPointerException when git repo is brand new (no commits) #57
Comments
I think it may be hard to decide just from the code if it's a "should panic" situation or "no git repo yet". You can use If anyone else has ideas - please share them here :) |
Git itself prints HEAD and then dies. I agree that some might want it to die, and others (me!) might want it to live. Seems too unimportant to add an option for? "die if repo empty" default == true? If not dying, you could use HEAD or EMPTY or something to signify it. The git dir IS there, just the contents don't make sense. Which is different to no git dir at all.
|
I feel like 'just commit "initial commit"' is a fine solution, but it does require the user to realize what the problem is. I can see this being confusing, especially for people who are new to git and don't really understand it in the first place, despite being competent enough to run Maven. Yes, they are out there. I have worked with some among their number. Seems like it would be nice to avoid the NPE at that critical moment and maybe print a helpful message suggesting they make sure their repo is fully-formed; maybe even just point to a wiki page here describing what they can look for to see whether this is their problem, and how to get past it. |
FWIW, this happens to to me almost daily, and it always takes me a second thought to realise why :-) Then I have to commit either everything, or just the pom, or whatever, then I have to amend that commit when I get to something that I really want to commit. It's not the end of the world, but it's definitely slightly annoying, especially if you make a lot of new repos from archetypes with this plugin in them ;-) |
Well the NPE is still present with the latest jgit-version. However the latest version of the plugin has two options to bypass any kind of exception:
I also reported the NPE to the jgit project: Not sure if they will fix it. Nevertheless as far as I understand this issue, the problem back in the days was that there had been no way to bypass exception(s) and the execution has failed. Questions, comments, or concerns? PS: |
Comments and thoughts:
|
Hi @fredcooke,
|
Hi @fredcooke, However, when running the plugin with the native-git implementation I'll get the following error with a brand new repro: This error will be produced when executing "git describe". Unfortunately this command can fail with the same message under a lot of different conditions. All of them depending on the configuration of the git describe (the maven-git-commit-id-plugin allows user to configure some options of the describe).
I'll leave the issue open, but as far as I can tell right now for the native implementation it will be really hard to distinguish between failOnUnableToExtractRepoInfo VS failOnNoGitDirectory. Not sure if this also apply for jgit-implementation. |
Hi @TheSnoozer |
[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.1.2:revision (default) on project abc: Execution default of goal pl.project13.maven:git-commit-id-plugin:2.1.2:revision failed. NullPointerException -> [Help 1]
This is on 2.1.2, 2.1.3 didn't make it to me yet. Maybe you don't care. Pretty obscure use-case :-) Feel free to close wont-fix if you like. Just wanted to document it.
The text was updated successfully, but these errors were encountered: