Thanks @bturner for the details
Indeed, when creating a file and commit it, the publish API does work for publishing the new commit.
It looks like it depends on the previous command we execute to get the repo in the right state.
We do:
git checkout -b COMMIT_SHA branch-name
Or in code:
GitWorkTreeBuilderFactory factory = ...
factory.builder(repo)
.alternate(source)
.checkoutType(GitCheckoutType.NONE)
.execute(worktree-> doGitOperations(worktree, sourceBranch));
.execute(worktree -> {
// Works in Bitbucket 7, but not 8
String checkoutResult = workTree.builder()
.author(author)
.command("checkout")
.argument("-b")
.argument(source.getId())
.argument(source.getLatestCommit())
.build(new SingleLineOutputHandler())
.call();
String noExistingCommit = "0000000000000000000000000000000000000000";
workTree.publish(new PublishGitWorkTreeParameters.Builder(invoker)
.branch("newly-published-branch", noExistingCommit)
.build());
}
Here is the code to demonstrate the issue:
https://bitbucket.org/RomanStoffel/bb8-worktree-issue/src/86bf5ae345454058ffa60e05da0cd0f361470dd0/src/main/java/ch/mibex/gitworktree/reproduce/api/TestGitWorktree.java#lines-91
It can be triggered by invoking the servlet:
curl -X POST --user admin:admin 'http://localhost:7990/bitbucket/plugins/servlet/mibex-git-worktree/project-admin/?proj=PROJECT_1&source=rep_1&target=test-repo'
Where there is a âsource=â is the source repo from where the latest commit is used, and âtargetâ is the empty repo.
From the Bitbucket mesh logs we get only this line:
2022-04-05 11:44:07,789 WARN [grpc-server:thread-5] admin 4T2JO83Qx704x26x2 @19Y6H0Wx704x24x0 127.0.0.1 "PlumbingService/CallStdin" (>1 <0) c.a.b.mesh.git.GrpcPlumbingService 'git checkout' is deprecated is not supported on remote repositories. Update the feature to use the higher level APIs if possible.
Not sure about this warning, we seem to get that one for all operations?