Created
April 5, 2016 14:12
-
-
Save Shaked/89e524451085675f8cbe35a0edd0422f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.rg.stash.plugin.commit.url.hook; | |
| import com.atlassian.stash.hook.*; | |
| import com.atlassian.stash.hook.repository.*; | |
| import com.atlassian.stash.repository.*; | |
| import java.util.Collection; | |
| public class UrlCommitHook implements PreReceiveRepositoryHook { | |
| /** | |
| * Disables deletion of branches | |
| */ | |
| public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse) { | |
| String projectKey = context.getRepository().getProject().getKey(); | |
| String slug = context.getRepository().getSlug(); | |
| String h = "http://localhost:7990"; // <--- how do I get this URL dynamically? | |
| String baseUrl = String.format("%s/stash/projects/%s/repos/%s/commits/", h, projectKey, slug); | |
| for (RefChange refChange : refChanges) { | |
| hookResponse.out().println(baseUrl + refChange.getToHash()); | |
| } | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment