All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.tech.build.axion.release.domain.hooks.CommitHookAction Maven / Gradle / Ivy

There is a newer version: 1.18.15
Show newest version
package pl.allegro.tech.build.axion.release.domain.hooks;

import pl.allegro.tech.build.axion.release.domain.hooks.ReleaseHookFactory.CustomAction;

public class CommitHookAction implements ReleaseHookAction {

    private final CustomAction customAction;

    public CommitHookAction(CustomAction customAction) {
        this.customAction = customAction;
    }

    public CommitHookAction() {
        this((hookContext) -> "Release version: " + hookContext.getCurrentVersion());
    }

    @Override
    public void act(HookContext hookContext) {
        String message = (customAction.apply(hookContext)).toString();
        hookContext.commit(hookContext.getPatternsToCommit(), message);
    }

    public final static class Factory extends DefaultReleaseHookFactory {
        @Override
        public ReleaseHookAction create() {
            return new CommitHookAction();
        }

        @Override
        public ReleaseHookAction create(CustomAction customAction) {
            return new CommitHookAction(customAction);
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy