Skip to content

Instantly share code, notes, and snippets.

@Shaked
Created April 5, 2016 14:12
Show Gist options
  • Select an option

  • Save Shaked/89e524451085675f8cbe35a0edd0422f to your computer and use it in GitHub Desktop.

Select an option

Save Shaked/89e524451085675f8cbe35a0edd0422f to your computer and use it in GitHub Desktop.
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