public static Run<?, ?> getBuildByBranch(Job<?, ?> project, String branchName) { for (Run<?, ?> build : project.getBuilds()) { BuildData data = build.getAction(BuildData.class); MergeRecord merge = build.getAction(MergeRecord.class); if (hasLastBuild(data) && isNoMergeBuild(data, merge)) { for (Branch branch : data.lastBuild.getRevision().getBranches()) { if (branch.getName().endsWith("/" + branchName)) { return build; } } } } return null; }
public boolean branchMatchesInterest(Branch br) { for (String regex : branches) { if (!Pattern.matches(regex, br.getName())) { return false; } } return true; }
public boolean branchMatchesInterest(Branch br) { for (String regex : branches) { if (!Pattern.matches(regex, br.getName())) { return false; } } return true; }
public boolean containsBranchName(String name) { for (Branch b : branches) { if (b.getName().equals(name)) { return true; } } return false; }
public boolean containsBranchName(String name) { for (Branch b : branches) { if (b.getName().equals(name)) { return true; } } return false; }
public boolean branchMatchesInterest(Branch br) { for (String regex : branches) { if (!Pattern.matches(regex, br.getName())) { return false; } } return true; }
private String format(Branch b) { String n = b.getName(); if (fullName) return n; return n.substring(n.indexOf('/')+1); // trim off '/' } }
/** * Returns whether the revision contains the specified branch. * * @param name the name of the branch * @return whether the revision contains the branch */ public boolean containsBranchName(String name) { return branches.stream().anyMatch(branch -> branch.getName().equals(name)); }
private String getBranchName(Branch branch) { String name = branch.getName(); if(name.startsWith("refs/remotes/")) { //Restore expected previous behaviour name = name.substring("refs/remotes/".length()); } return name; }
public List<Branch> filterMatchingBranches(Collection<Branch> branches, EnvVars env) { List<Branch> items = new ArrayList<>(); for(Branch b : branches) { if(matches(b.getName(), env)) items.add(b); } return items; }
public String toString() { String s = "Revision " + sha1.name() + " ("; for (Branch br : branches) { s += br.getName() + ", "; } if (s.endsWith(", ")) { s = s.substring(0, s.length() - 2); } s += ")"; return s; }
public List<Branch> filterMatchingBranches(Collection<Branch> branches) { List<Branch> items = new ArrayList<Branch>(); for (Branch b : branches) { if (matches(b.getName())) { items.add(b); } } return items; }
public String toString() { String s = "Revision " + sha1.name() + " ("; for (Branch br : branches) { s += br.getName() + ", "; } if (s.endsWith(", ")) { s = s.substring(0, s.length() - 2); } s += ")"; return s; }
public List<Branch> filterMatchingBranches(Collection<Branch> branches) { List<Branch> items = new ArrayList<Branch>(); for (Branch b : branches) { if (matches(b.getName())) { items.add(b); } } return items; }
protected List<Branch> parseRefList(List<Ref> refList) { List<Branch> result = new ArrayList<Branch>(); if (CollectionUtils.isNotEmpty(refList)) { for (Ref ref : refList) { Branch buildBranch = new Branch(ref); result.add(buildBranch); listener.getLogger().println(Messages.GitAPI_Branch_BranchInRepoMsg(buildBranch.getName())); } } return result; }
protected GitTagAction(Run build, FilePath workspace, Revision revision) { super(build); this.ws = workspace.getRemote(); for (Branch b : revision.getBranches()) { tags.put(b.getName(), new ArrayList<String>()); } }
public void saveBuild(Build build) { lastBuild = build; for (Branch branch : build.revision.getBranches()) { buildsByBranchName.put(fixNull(branch.getName()), build); } }
public void saveBuild(Build build) { lastBuild = build; for (Branch branch : build.revision.getBranches()) { buildsByBranchName.put(fixNull(branch.getName()), build); } }
private String getLastSuccessfulBuiltCommitOfBranch(Run<?, ?> build, Branch branch) { String prevCommit = null; if (build.getPreviousSuccessfulBuild() != null) { final Build lastSuccessfulBuildOfBranch = fixNull(getBuildData(build.getPreviousSuccessfulBuild())).getLastBuildOfBranch(branch.getName()); if (lastSuccessfulBuildOfBranch != null) { Revision previousRev = lastSuccessfulBuildOfBranch.getRevision(); if (previousRev != null) { prevCommit = previousRev.getSha1String(); } } } return prevCommit; }