Hi All,
I want to apply some validation on commit message.
How can I achieve this.
I got one sample in github i.e., https://github.com/sford/yet-another-commit-checker
there they used for jira services so I thought it not suited for my requirement because some of the classes I'm not able to import.
I'm using stash server and atlas-sdk. created pre repository hook. and I modified for getting commit message like below in my class.
public class MyPreReceiveRepositoryHook implements PreReceiveRepositoryHook
{
private CommitService commitService;
public MyPreReceiveRepositoryHook(CommitService commitService) {
this.commitService = commitService;
}
public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse)
{
final ChangesetsBetweenRequest request = new ChangesetsBetweenRequest.Builder(context.getRepository()) .exclude(((RefChange)refChanges).getFromHash()).include(((RefChange)refChanges).getToHash()) .build();
final Page<Changeset> cs = commitService.getChangesetsBetween(request, new PageRequestImpl(0, PageRequest.MAX_PAGE_LIMIT));
String commitMessage;
for(Changeset changeset: cs.getValues())
{
commitMessage = changeset.getMessage();
hookResponse.out().println(commitMessage);
}
return true;
}
}
With this I want to see the commit messages but I got this error on Git(client console).
remote: Hook com.konylabs.stash.plugin.hook.MyPreReceiveRepositoryHook failed. Error:
remote: com.google.common.collect.SingletonImmutableList cannot be cast to com.atlassian.stash.repository.RefChange
Regards
Anil