Hello,
I’m working on a project which use bitbucket server SDK to develop a plugin which will check whether a specific file is modified in a pull request. If it’s modified, we need to take some additional actions.
I’m currently trying to implement a class which implements RepositoryMergeCheck
interface. In the preUpdate
method, I can get a PreRepositoryHookContext
object as well as a PullRequestMergeHookRequest
. But how can I get the list of strings which contains the filename of modified files in this commit?
Any ideas?
1 Like
Hi @tommy.zhang,
You can use CommitService#getChanges() to retrieve the changes between two commits. The from since
and until
commit can be obtained from PullRequestMergeHookRequest#getMergeHash() and PullRequestMergeHookRequest#getToRef().
Cheers,
Justin
2 Likes
Thanks Justin,
That’s very helpful for me. However, it seems that CommitService
is only an interface. I still need to write my own class implementing that interface. I still have no idea how to get the content of a commit rather than just getting some meta-info.
Sincerely,
Tommy
Hi @tommy.zhang,
Have a look at the example plugin on how to inject services provided by Bitbucket. You can use similar approach to inject CommitService
.
The full tutorial can be found here
Cheers,
Justin