ajoberstar/gradle-git-publish

gitPublishReset fails when repoUri points to empty repo

Closed this issue · 11 comments

Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Checkout returned unexpected result NO_CHANGE
        at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:244)
        at org.eclipse.jgit.api.CheckoutCommand.call(CheckoutCommand.java:1)
        at java_util_concurrent_Callable$call$0.call(Unknown Source)
        at org.ajoberstar.grgit.operation.CheckoutOp.call(CheckoutOp.groovy:62)
        at org.ajoberstar.grgit.operation.CheckoutOp.call(CheckoutOp.groovy)
        at java_util_concurrent_Callable$call.call(Unknown Source)
        at java_util_concurrent_Callable$call.call(Unknown Source)
        at org.ajoberstar.grgit.internal.OpSyntax.samOperation(OpSyntax.groovy:26)
        at org.ajoberstar.grgit.internal.OpSyntax$samOperation.callStatic(Unknown Source)
        at org.ajoberstar.grgit.Grgit.checkout(Grgit.groovy)
        at org.ajoberstar.gradle.git.publish.tasks.GitPublishReset.reset(GitPublishReset.java:121)

When first checking out an empty repo.

Gradle 4.10.3
org.ajoberstar:gradle-git-publish:2.0.0

Creating a root commit on that branch works around the issue.

@shevek Thanks for reporting this. I have a couple questions about the scenario:

  • Is it the repo pointed at with gitPublish.repoUri that's empty?
  • Are you publishing to a different repo than your project or is this just when you run gitPublishPush before pushing up your master branch?

(1) yes, when the target repo was freshly created on github with no commits, this happened. The moment I put a root commit in with a README, it worked just fine.
(2) If I understand correctly, yes, project in repo A is pushing a commit into repo B, and repo B was previously empty.

Plugin is working great now that repo B has at least one commit in it.

Good to know, will fix in next round of updates.

It's a sufficiently obscure circumstance that any regular user won't hit it, of course. Reminds me of reporting a bug to the ASF which only occurred if you RAN the code on Feb 29th. By the time they reran my test case a week later, of course it passed.

Having trouble reproducing this in a test. Here's the last iteration I tried 082a56d.

  • Start with an empty remote right away, seemed to just work as expected
  • Start with valid remote, do a successful gitPublishPush change, change the repoUri to a new empty repo, and try again, still seems to work
  • Start with valid remote, do a successful gitPublishPush change, delete the remote and re-initialize to an empty repo, try again, fails for ref already exists.

If you have some time, I'd appreciate some help reproducing.

Are we distinguishing empty root commit vs no root commit? Will look again when I get chance.

My test was for no root commit, didn't try empty root commit.

Hi, I don't know if this is related, but I'm getting the same error when specifying a branch that doesn't exist in the remote repository.

gradle 4.10.2
git-publish 2.1.1

Upgrading to Gradle 5.6.2 seems to resolve the issue.

Closing under the assumption this is resolved. If that's not true and you want to discuss further, please reopen.