I started writing you a response, and then realised that I'd already answered this on Answers (which was what I was going to suggest as well).
Cheers, Charles
문제
I need help on how to successfully create a RepositoryMergeRequestCheck
As part of our merge workflow, we need to ensure some policies about some files. Policies includes among others:
I want to be able to check for this policies on a repository merge request check so I’m building a plugin for Astlassian Stash
I have tried the following approaches:
Using the RepositoryMergeRequestCheckContext
parameter of RepositoryMergeRequestCheck.check()
Since the method signature is:
@Override
public void check(RepositoryMergeRequestCheckContext context)
The first thing I tried using was the context parameter. I can say context.getMergeRequest().getPullRequest().getFromRef().getRepository()
Now I get a Repository instance and I’m not sure how to extract commit info from it.
Calling Git directly: Since this check was originally developed as a git hook script, calling git from the SDK made sense to me. It led me to this situation:
String result = gitScm.getCommandBuilderFactory().builder().lsTree().build(…).call();
Where gitScm gets dependency injected in the plugin’s constructor.
Notice the build parameter? It expects a CommandOutputHandler<T>
in this case T is string, but that’s an interface, and I’m not sure how to get an instance that implements that interface or how to create one.
What path should I follow or how can I do it?
해결책
I started writing you a response, and then realised that I'd already answered this on Answers (which was what I was going to suggest as well).
Cheers, Charles