Skip to content

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

Closed

Description

@alexnederlof

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.

Activity

  1. ghost assigned on Jan 31, 2013
  2. ktoso commented on Jan 31, 2013

    @ktoso
    Collaborator

    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? :)

  3. alexnederlof commented on Feb 1, 2013

    @alexnederlof
    Author

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

    Thanks!

  4. BFinnigan commented on Feb 19, 2013

    @BFinnigan

    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.

  5. alexnederlof commented on Feb 20, 2013

    @alexnederlof
    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

  6. BFinnigan commented on Feb 20, 2013

    @BFinnigan

    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.

  7. ktoso commented on Mar 25, 2013

    @ktoso
    Collaborator

    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]
    
  8. added a commit that references this issue on Mar 25, 2013
  9. TheSnoozer commented on Mar 6, 2014

    @TheSnoozer
    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.

  10. added a commit that references this issue on Mar 6, 2014
  11. rmetzger commented on Jul 12, 2014

    @rmetzger

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

    git:
      depth: 500
  12. TheSnoozer commented on Apr 8, 2015

    @TheSnoozer
    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.

  13. julianhyde commented on Dec 2, 2015

    @julianhyde

    Thanks @rmetzger - your workaround worked for me.

  14. added this to the 2.1.10 milestone on Sep 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions