PageRenderTime 14ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 2ms app.codeStats 0ms

/plugin-module-codegen-engine/src/main/resources/templates/stash/repository-hook/PreReceiveRepositoryHook.java.vtl

https://bitbucket.org/mmeinhold/amps
Unknown | 26 lines | 24 code | 2 blank | 0 comment | 0 complexity | 4f056ad5c56dd9f5b7c78549d4ad7df5 MD5 | raw file
 1package ${PACKAGE};
 2
 3import com.atlassian.stash.hook.*;
 4import com.atlassian.stash.hook.repository.*;
 5import com.atlassian.stash.repository.*;
 6import java.util.Collection;
 7
 8public class ${CLASSNAME} implements PreReceiveRepositoryHook
 9{
10    /**
11     * Disables deletion of branches
12     */
13    @Override
14    public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse)
15    {
16        for (RefChange refChange : refChanges)
17        {
18            if (refChange.getType() == RefChangeType.DELETE)
19            {
20                hookResponse.err().println("The ref '" + refChange.getRefId() + "' cannot be deleted.");
21                return false;
22            }
23        }
24        return true;
25    }
26}