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

The plugin fails when it can't find a revision #63

Closed
alexnederlof opened this issue Jan 28, 2013 · 10 comments
Closed

The plugin fails when it can't find a revision #63

alexnederlof opened this issue Jan 28, 2013 · 10 comments
Assignees
Milestone

Comments

@alexnederlof
Copy link

The plugin fails when it can't find a revision. I think it happend because someone amended a commit. It could also be because travis doesn't fetch all revisions.

You can reproduce the problem like this:

git clone --depth=100 --quiet --branch=branchname git://github.com/crawljax/crawljax.git
cd crawljax
git checkout -qf 8c2e0f52d27c33df5e1c4c2deec472b1e138d67a
mvn clean package -DskipTests=true

This results in the error:

[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.1.4:revision (default) on project crawljax-core: Execution default of goal pl.project13.maven:git-commit-id-plugin:2.1.4:revision failed: Unable to calculate distance between [commit 8c2e0f52d27c33df5e1c4c2deec472b1e138d67a 1359301377 ----sp] and [commit c8c9b49da0750d39f51b282e29f70672fb657b65 1356953576 ----sp]: Missing commit a19d505b92d4e73d39ab554cff26dc59dc8e25a9 -> [Help 1]

Here's an example of a failed build

I don't mind that it doesn't work, but it shouldn't break the build IMHO.

@ktoso
Copy link
Collaborator

ktoso commented Jan 31, 2013

Hey Alex,
thanks for reporting this!

Yeap I see why and can imagine other build servers doing flat checkouts too... Though on a private server you could control that... but not so much on travis.

How about we add an option similar to failOnNoGitDirectory, which would be for example... failOnUnableToExtractRepoInfo = false - that'd save the build from failing on travis :)

I'd rather hide it under an option to allow users to decide if this is a very bad situation for them of if they just don't care.

Sounds good enough? :)

@alexnederlof
Copy link
Author

Sounds perfect! It's just a use-case for Travis as far as I know. Jenkins doesn't have the problem.

Thanks!

@BFinnigan
Copy link

Is there a workaround for this in the meantime? Something that I can do in git to make it work? Just hit this as a blocker from me checking in my POM updates.

@alexnederlof
Copy link
Author

My work around was to activate the plugin only with certain profiles.

On Tuesday, February 19, 2013, Brobble wrote:

Is there a workaround for this in the meantime? Something that I can do in
git to make it work? Just hit this as a blocker from me checking in my POM
updates.


Reply to this email directly or view it on GitHubhttps://github.com//issues/63#issuecomment-13804265.

Sent from my mobile

@BFinnigan
Copy link

My problem is that I am using bamboo for CI and I actually want it to produce the git.properties file. I was hoping for a way to "repair" git so that the plugin would still work. Sounds like if there is a flag that just ignore the git.properties not being produced it wouldn't work for me.

@ktoso
Copy link
Collaborator

ktoso commented Mar 25, 2013

I'm on it guys :-) Cheers from a Cafe in Kraków.

Just a small paste for future reference:

[INFO] --- git-commit-id-plugin:2.1.4:revision (default) @ crawljax-core ---
[info] --always = true
[info] --dirty = "-dirty"
[info] --abbrev = 7
[info] --match = ""
[info] Tag refs [[Ref[refs/tags/crawljax-2.1=2e6861d1e511b31d372fd5561d12b3a0447d206e], Ref[refs/tags/crawljax-2.2=752f00bd16229fbae6341291f2a9393bcce98be0]]]
[info] Resolved tag [crawljax-2.1] [PersonIdent[Ali Mesbah, amesbah@gmail.com, Wed Dec 12 20:39:04 2012 -0800]], points at [commit 28666d079c9990fbc3d4ae096006a35d85b634e4 0 ------]
[info] Resolved tag [crawljax-2.2] [PersonIdent[Alex Nederlof, alex@nederlof.com, Mon Dec 31 12:33:00 2012 +0100]], points at [commit c8c9b49da0750d39f51b282e29f70672fb657b65 0 ------]
[info] key [commit 28666d079c9990fbc3d4ae096006a35d85b634e4 0 ------], tags => [[DatedRevTag{id=2e6861d1e511b31d372fd5561d12b3a0447d206e, tagName='crawljax-2.1', date=December 13, 2012 5:39:04 AM CET}]]
[info] key [commit c8c9b49da0750d39f51b282e29f70672fb657b65 0 ------], tags => [[DatedRevTag{id=752f00bd16229fbae6341291f2a9393bcce98be0, tagName='crawljax-2.2', date=December 31, 2012 12:33:00 PM CET}]]
[info] Created map: [{commit 28666d079c9990fbc3d4ae096006a35d85b634e4 0 ------=[crawljax-2.1], commit c8c9b49da0750d39f51b282e29f70672fb657b65 0 ------=[crawljax-2.2]}]
[info] HEAD is [8c2e0f52d27c33df5e1c4c2deec472b1e138d67a]
[info] Repo is in dirty state [false]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Crawljax parent POM ............................... SUCCESS [22.964s]
[INFO] Crawljax .......................................... FAILURE [4:04.509s]
[INFO] Crawljax CLI ...................................... SKIPPED
[INFO] Crawljax Examples ................................. SKIPPED
[INFO] Crawljax test utilities ........................... SKIPPED
[INFO] Crawljax plugins parent POM ....................... SKIPPED
[INFO] Crawljax plugins archetype ........................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4:27.759s
[INFO] Finished at: Mon Mar 25 19:21:13 CET 2013
[INFO] Final Memory: 12M/135M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.1.4:revision (default) on project crawljax-core: Execution default of goal pl.project13.maven:git-commit-id-plugin:2.1.4:revision failed: Unable to calculate distance between [commit 8c2e0f52d27c33df5e1c4c2deec472b1e138d67a 1359301377 ----sp] and [commit c8c9b49da0750d39f51b282e29f70672fb657b65 1356953576 ----sp]: Missing commit 4555ed399816bf920ff0d3efd8771976826d8fb5 -> [Help 1]

ktoso added a commit that referenced this issue Mar 25, 2013
@TheSnoozer
Copy link
Collaborator

Unfortunately with version 2.1.9 this problem is still open:

[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to calculate distance between [commit 0bce3c122a48386c2f79d4fe9db2541e484e20d7 1394111047 ----sp] and [commit f1ef9e92d2a55475472bc203b2cc6e03cfb401ca 1393494246 ----sp]
Missing commit 05a4f1269b1b22de00517c1983a2538031dff94d
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.RuntimeException: Unable to calculate distance between [commit 0bce3c122a48386c2f79d4fe9db2541e484e20d7 1394111047 ----sp] and [commit f1ef9e92d2a55475472bc203b2cc6e03cfb401ca 1393494246 ----sp]
    at pl.project13.jgit.DescribeCommand.distanceBetween(DescribeCommand.java:488)
    at pl.project13.jgit.DescribeCommand.call(DescribeCommand.java:333)
    at pl.project13.maven.git.GitCommitIdMojo.putGitDescribe(GitCommitIdMojo.java:509)
    at pl.project13.maven.git.GitCommitIdMojo.maybePutGitDescribe(GitCommitIdMojo.java:502)
    at pl.project13.maven.git.GitCommitIdMojo.loadGitData(GitCommitIdMojo.java:448)
    at pl.project13.maven.git.GitCommitIdMojo.execute(GitCommitIdMojo.java:307)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.eclipse.jgit.errors.MissingObjectException: Missing commit 05a4f1269b1b22de00517c1983a2538031dff94d
    at org.eclipse.jgit.storage.file.WindowCursor.open(WindowCursor.java:126)
    at org.eclipse.jgit.revwalk.RevWalk.getCachedBytes(RevWalk.java:856)
    at org.eclipse.jgit.revwalk.RevCommit.parseHeaders(RevCommit.java:136)
    at org.eclipse.jgit.revwalk.RevWalk.parseHeaders(RevWalk.java:965)
    at org.eclipse.jgit.revwalk.RevWalk.parseAny(RevWalk.java:814)
    at org.eclipse.jgit.revwalk.RevWalk.parseCommit(RevWalk.java:725)
    at pl.project13.jgit.DescribeCommand.seeAllParents(DescribeCommand.java:505)
    at pl.project13.jgit.DescribeCommand.distanceBetween(DescribeCommand.java:466)
    ... 24 more

my pom looks like:

<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.1.9</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<prefix>git</prefix>
<dateFormat>dd.MM.yyyy '@' HH:mm:ss z</dateFormat>
<verbose>false</verbose>
<dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
<skipPoms>true</skipPoms>
<generateGitPropertiesFile>false</generateGitPropertiesFile>
<generateGitPropertiesFilename>target/classes/git.properties</generateGitPropertiesFilename>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
<gitDescribe>
<skip>false</skip>
<always>true</always>
<abbrev>8</abbrev>
<forceLongFormat>false</forceLongFormat>
</gitDescribe>
</configuration>
</plugin>

Can you fix this?
Cheers

PS: you should change LN 319 of GitCommitIdMojo.java to a catch Exception instead of a IOException and it should work again.

@rmetzger
Copy link

I think you can increase the "clone depth" of travis in the .travis.yml file with:

git:
  depth: 500

@TheSnoozer
Copy link
Collaborator

The latest version of the plugin has two options to bypass any kind of exception:

<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>

failOnUnableToExtractRepoInfo was introduced with this issue
failOnNoGitDirectory was introduced with #26

Thanks for reporting and the support to track the problem down.

julianhyde added a commit to hydromatic/quidem that referenced this issue Dec 2, 2015
@julianhyde
Copy link

Thanks @rmetzger - your workaround worked for me.

julianhyde added a commit to hydromatic/quidem that referenced this issue Dec 2, 2015
@TheSnoozer TheSnoozer added this to the 2.1.10 milestone Sep 23, 2017
julianhyde added a commit to hydromatic/quidem that referenced this issue Nov 8, 2021
The build plugin fails in Travis with the message "Execution default of goal pl.project13.maven:git-commit-id-plugin:2.1.9:revision failed: Unable to calculate distance between [commit abcd] and [commit cdef]: Missing commit ef12".

We upgrade the plugin, and use the configuration property
`failOnUnableToExtractRepoInfo`.

See git-commit-id/git-commit-id-maven-plugin#63
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

6 participants