From bc7422ea4ca0f18ffeae7a0449ad5431b535d3f9 Mon Sep 17 00:00:00 2001 From: David Rubin Date: Tue, 7 Feb 2012 11:06:00 +0200 Subject: [PATCH] Added branch support, in theory it works but does not in practise (but neither do the others tag/revision) --- .../gitparameter/GitParameterDefinition.java | 22 ++++++++++++++++++- .../GitParameterDefinition/config.jelly | 10 ++++++++- .../GitParameterDefinition/help-type.html | 1 + .../GitParameterDefinition/index.jelly | 10 +++++++++ 4 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java b/src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java index 285ff4a..620b09d 100644 --- a/src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java +++ b/src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java @@ -36,6 +36,8 @@ import hudson.plugins.git.IGitAPI; import hudson.plugins.git.GitAPI; import hudson.plugins.git.Revision; +import hudson.plugins.git.Branch; + public class GitParameterDefinition extends ParameterDefinition { @@ -44,6 +46,8 @@ public class GitParameterDefinition extends ParameterDefinition { public static final String PARAMETER_TYPE_TAG = "PT_TAG"; public static final String PARAMETER_TYPE_REVISION = "PT_REVISION"; + + public static final String PARAMETER_TYPE_BRANCH = "PT_BRANCH"; @Extension public static class DescriptorImpl extends ParameterDescriptor { @@ -61,6 +65,8 @@ public String getDisplayName() { private Map revisionMap; private Map tagMap; + private Map branchMap; + @DataBoundConstructor public GitParameterDefinition(String name, @@ -200,7 +206,14 @@ public void generateContents(String contenttype) { for(String tagName: newgit.getTagNames("*")) { tagMap.put(tagName, tagName); } - } + } else if(type.equalsIgnoreCase(PARAMETER_TYPE_BRANCH)) { + branchMap = new HashMap(); + + //Set tagNameList = newgit.getTagNames("*"); + for(Branch branch: newgit.getBranches()) { + branchMap.put(branch.getSHA1String(), branch.toString()); + } + } } } @@ -226,5 +239,12 @@ public Map getTagMap() { return tagMap; } + public Map getBranchMap() { + if( branchMap == null || branchMap.isEmpty()){ + generateContents(PARAMETER_TYPE_BRANCH); + } + return branchMap; + } + } diff --git a/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/config.jelly b/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/config.jelly index ed3c804..e2b813d 100644 --- a/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/config.jelly +++ b/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/config.jelly @@ -22,7 +22,15 @@ - + + + + + + + + + diff --git a/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/help-type.html b/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/help-type.html index 8e0b2d7..9b94895 100644 --- a/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/help-type.html +++ b/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/help-type.html @@ -2,6 +2,7 @@ The type of the list of parameters:
  • Tag - list of all commit tags in repository - returns Tag Name
  • +
  • Branch - list of all commit branches in repository - returns Branch Name
  • Revision - list of all revision sha1 in repository followed by its author and date - returns Tag SHA1
diff --git a/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/index.jelly b/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/index.jelly index 6f6a0a0..f06fc12 100644 --- a/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/index.jelly +++ b/src/main/resources/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition/index.jelly @@ -26,6 +26,16 @@ + + + +