Bitbucket API GitRevListBuilder throwing commit does not exsist exception

Bitbucket version: 4.9.1

I’ve been working on a Bitbucket Hook plugin and my initial goal is to create a plugin which will allow me to reject a commit based on the commit author. I’ve been using an open source hook as a reference (Yet Another Commit Checker)

I am currently attempting to parse the commit using GitRevListBuilder from the Bitbucket API using something along the lines of

GitRevListBuilder revListBuilder = ((GitScmCommandBuilder)scmService.createBuilder(repository)).revList()
					.format("%H%x02%P%x02%cN%x02%cE%n%B%n%x03END%x04")
					.revs(rf.getToHash()), "--not","--all");

names = revListBuilder.build(new commitListOutputHandler()).call();

but every time I run the build method I get an exception

 Commit '9bd33f587458bf9fb69ca1bcd5a39579be20e5fa' does not exist in repository 'rep_1'.

the commit in the exception corresponds to the commit I am trying to push.

This strategy is being used by a live plugin so ostensibly it should work but I am guessing that I am forgetting subtle detail.

Seems logical that the commit would not yet be in the repository if you are attempting to push it.

Not debating that but I kind of need a way to access that commit. not to mention that another addon is using that exact method so I was not sure if the repository hook treats the commit as being in the repo for it’s purposes prior to accepting the commit.

Hi @james.wagner,

What version of git is running on the server? git 2.11 changed where pre-receive data is put, which broke pre-receive hooks on Bitbucket Server. Bitbucket Server 4.11.2+ is compatible with git 2.11 but you also need to make sure your plugin is based off a version of YACC that is also compatible with 2.11.

There are some more details here:

I hope that helps,

– Brent

Ah, perfect. I was using Git 2.13 for windows and when I downgraded to 2.10.2 the GitRevListBuilder build method stopped throwing exceptions for missing commits.

Thank You