org.kohsuke.accmod.restrictions.DoNotUse Java Examples

The following examples show how to use org.kohsuke.accmod.restrictions.DoNotUse. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param buildOriginBranch see {@link BranchDiscoveryTrait#BranchDiscoveryTrait(boolean, boolean)}.
 * @deprecated use {@link BranchDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginBranch(boolean buildOriginBranch) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof BranchDiscoveryTrait) {
            BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait;
            if (buildOriginBranch || previous.isBuildBranchesWithPR()) {
                traits.set(i, new BranchDiscoveryTrait(buildOriginBranch, previous.isBuildBranchesWithPR()));
            } else {
                traits.remove(i);
            }
            return;
        }
    }
    if (buildOriginBranch) {
        traits.add(new BranchDiscoveryTrait(buildOriginBranch, false));
    }
}
 
Example #2
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setIncludes(@NonNull String includes) {
    for (int i = 0; i < traits.size(); i++) {
        SCMSourceTrait trait = traits.get(i);
        if (trait instanceof WildcardSCMHeadFilterTrait) {
            WildcardSCMHeadFilterTrait existing = (WildcardSCMHeadFilterTrait) trait;
            if ("*".equals(includes) && "".equals(existing.getExcludes())) {
                traits.remove(i);
            } else {
                traits.set(i, new WildcardSCMHeadFilterTrait(includes, existing.getExcludes()));
            }
            return;
        }
    }
    if (!"*".equals(includes)) {
        traits.add(new WildcardSCMHeadFilterTrait(includes, ""));
    }
}
 
Example #3
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginBranch(boolean buildOriginBranch) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof BranchDiscoveryTrait) {
            BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait;
            if (buildOriginBranch || previous.isBuildBranchesWithPR()) {
                traits.set(i, new BranchDiscoveryTrait(buildOriginBranch, previous.isBuildBranchesWithPR()));
            } else {
                traits.remove(i);
            }
            return;
        }
    }
    if (buildOriginBranch) {
        traits.add(new BranchDiscoveryTrait(buildOriginBranch, false));
    }
}
 
Example #4
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginBranchWithPR(boolean buildOriginBranchWithPR) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof BranchDiscoveryTrait) {
            BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait;
            if (buildOriginBranchWithPR || previous.isBuildBranch()) {
                traits.set(i, new BranchDiscoveryTrait(previous.isBuildBranch(), buildOriginBranchWithPR));
            } else {
                traits.remove(i);
            }
            return;
        }
    }
    if (buildOriginBranchWithPR) {
        traits.add(new BranchDiscoveryTrait(false, buildOriginBranchWithPR));
    }
}
 
Example #5
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginPRMerge(boolean buildOriginPRMerge) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof OriginPullRequestDiscoveryTrait) {
            Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies();
            if (buildOriginPRMerge) {
                s.add(ChangeRequestCheckoutStrategy.MERGE);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.MERGE);
            }
            traits.set(i, new OriginPullRequestDiscoveryTrait(s));
            return;
        }
    }
    if (buildOriginPRMerge) {
        traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE)));
    }
}
 
Example #6
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginPRHead(boolean buildOriginPRHead) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof OriginPullRequestDiscoveryTrait) {
            Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies();
            if (buildOriginPRHead) {
                s.add(ChangeRequestCheckoutStrategy.HEAD);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.HEAD);
            }
            traits.set(i, new OriginPullRequestDiscoveryTrait(s));
            return;
        }
    }
    if (buildOriginPRHead) {
        traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD)));
    }
}
 
Example #7
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildForkPRMerge(boolean buildForkPRMerge) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof ForkPullRequestDiscoveryTrait) {
            ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait;
            Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies();
            if (buildForkPRMerge) {
                s.add(ChangeRequestCheckoutStrategy.MERGE);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.MERGE);
            }
            traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust()));
            return;
        }
    }
    if (buildForkPRMerge) {
        traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE),
                new ForkPullRequestDiscoveryTrait.TrustPermission()));
    }
}
 
Example #8
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy constructor.
 *
 * @param apiUri                the API endpoint for the GitHub server.
 * @param repoOwner             the owner of the repositories to navigate.
 * @param scanCredentialsId     the credentials to use when accessing {@link #apiUri} (and also the default
 *                              credentials to use for checking out).
 * @param checkoutCredentialsId the credentials to use when checking out.
 * @deprecated use {@link #GitHubSCMNavigator(String)}, {@link #setApiUri(String)},
 * {@link #setCredentialsId(String)} and {@link SSHCheckoutTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public GitHubSCMNavigator(String apiUri, String repoOwner, String scanCredentialsId, String checkoutCredentialsId) {
    this(repoOwner);
    setCredentialsId(scanCredentialsId);
    setApiUri(apiUri);
    // legacy constructor means legacy defaults
    this.traits = new ArrayList<>();
    this.traits.add(new BranchDiscoveryTrait(true, true));
    this.traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE),
            new ForkPullRequestDiscoveryTrait.TrustPermission()));
    if (!GitHubSCMSource.DescriptorImpl.SAME.equals(checkoutCredentialsId)) {
        traits.add(new SSHCheckoutTrait(checkoutCredentialsId));
    }
}
 
Example #9
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param includes see {@link WildcardSCMHeadFilterTrait#WildcardSCMHeadFilterTrait(String, String)}
 * @deprecated use {@link WildcardSCMHeadFilterTrait}.
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setIncludes(@NonNull String includes) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof WildcardSCMHeadFilterTrait) {
            WildcardSCMHeadFilterTrait existing = (WildcardSCMHeadFilterTrait) trait;
            if ("*".equals(includes) && "".equals(existing.getExcludes())) {
                traits.remove(i);
            } else {
                traits.set(i, new WildcardSCMHeadFilterTrait(includes, existing.getExcludes()));
            }
            return;
        }
    }
    if (!"*".equals(includes)) {
        traits.add(new WildcardSCMHeadFilterTrait(includes, ""));
    }
}
 
Example #10
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildForkPRHead(boolean buildForkPRHead) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof ForkPullRequestDiscoveryTrait) {
            ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait;
            Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies();
            if (buildForkPRHead) {
                s.add(ChangeRequestCheckoutStrategy.HEAD);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.HEAD);
            }
            traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust()));
            return;
        }
    }
    if (buildForkPRHead) {
        traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD),
                new ForkPullRequestDiscoveryTrait.TrustPermission()));
    }
}
 
Example #11
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param buildOriginBranchWithPR see {@link BranchDiscoveryTrait#BranchDiscoveryTrait(boolean, boolean)}.
 * @deprecated use {@link BranchDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginBranchWithPR(boolean buildOriginBranchWithPR) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof BranchDiscoveryTrait) {
            BranchDiscoveryTrait previous = (BranchDiscoveryTrait) trait;
            if (buildOriginBranchWithPR || previous.isBuildBranch()) {
                traits.set(i, new BranchDiscoveryTrait(previous.isBuildBranch(), buildOriginBranchWithPR));
            } else {
                traits.remove(i);
            }
            return;
        }
    }
    if (buildOriginBranchWithPR) {
        traits.add(new BranchDiscoveryTrait(false, buildOriginBranchWithPR));
    }
}
 
Example #12
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param buildOriginPRMerge see {@link OriginPullRequestDiscoveryTrait#OriginPullRequestDiscoveryTrait(Set)}.
 * @deprecated use {@link OriginPullRequestDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginPRMerge(boolean buildOriginPRMerge) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof OriginPullRequestDiscoveryTrait) {
            Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies();
            if (buildOriginPRMerge) {
                s.add(ChangeRequestCheckoutStrategy.MERGE);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.MERGE);
            }
            traits.set(i, new OriginPullRequestDiscoveryTrait(s));
            return;
        }
    }
    if (buildOriginPRMerge) {
        traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE)));
    }
}
 
Example #13
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param buildOriginPRHead see {@link OriginPullRequestDiscoveryTrait#OriginPullRequestDiscoveryTrait(Set)}.
 * @deprecated use {@link OriginPullRequestDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildOriginPRHead(boolean buildOriginPRHead) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof OriginPullRequestDiscoveryTrait) {
            Set<ChangeRequestCheckoutStrategy> s = ((OriginPullRequestDiscoveryTrait) trait).getStrategies();
            if (buildOriginPRHead) {
                s.add(ChangeRequestCheckoutStrategy.HEAD);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.HEAD);
            }
            traits.set(i, new OriginPullRequestDiscoveryTrait(s));
            return;
        }
    }
    if (buildOriginPRHead) {
        traits.add(new OriginPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD)));
    }
}
 
Example #14
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param buildForkPRMerge see {@link ForkPullRequestDiscoveryTrait#ForkPullRequestDiscoveryTrait(Set, SCMHeadAuthority)}.
 * @deprecated use {@link ForkPullRequestDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildForkPRMerge(boolean buildForkPRMerge) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof ForkPullRequestDiscoveryTrait) {
            ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait;
            Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies();
            if (buildForkPRMerge) {
                s.add(ChangeRequestCheckoutStrategy.MERGE);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.MERGE);
            }
            traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust()));
            return;
        }
    }
    if (buildForkPRMerge) {
        traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.MERGE),
                new ForkPullRequestDiscoveryTrait.TrustPermission()));
    }
}
 
Example #15
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param buildForkPRHead see
 * {@link ForkPullRequestDiscoveryTrait#ForkPullRequestDiscoveryTrait(Set, SCMHeadAuthority)}.
 * @deprecated use {@link ForkPullRequestDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBuildForkPRHead(boolean buildForkPRHead) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof ForkPullRequestDiscoveryTrait) {
            ForkPullRequestDiscoveryTrait forkTrait = (ForkPullRequestDiscoveryTrait) trait;
            Set<ChangeRequestCheckoutStrategy> s = forkTrait.getStrategies();
            if (buildForkPRHead) {
                s.add(ChangeRequestCheckoutStrategy.HEAD);
            } else {
                s.remove(ChangeRequestCheckoutStrategy.HEAD);
            }
            traits.set(i, new ForkPullRequestDiscoveryTrait(s, forkTrait.getTrust()));
            return;
        }
    }
    if (buildForkPRHead) {
        traits.add(new ForkPullRequestDiscoveryTrait(EnumSet.of(ChangeRequestCheckoutStrategy.HEAD),
                new ForkPullRequestDiscoveryTrait.TrustPermission()));
    }
}
 
Example #16
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy getter.
 *
 * @return {@link SSHCheckoutTrait#getCredentialsId()} with some mangling to preserve legacy behaviour.
 * @deprecated use {@link SSHCheckoutTrait}
 */
@CheckForNull
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public String getCheckoutCredentialsId() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof SSHCheckoutTrait) {
            return StringUtils.defaultString(
                    ((SSHCheckoutTrait) trait).getCredentialsId(),
                    GitHubSCMSource.DescriptorImpl.ANONYMOUS
            );
        }
    }
    return DescriptorImpl.SAME;
}
 
Example #17
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 6 votes vote down vote up
/**
 * Legacy setter.
 *
 * @param pattern see {@link RegexSCMSourceFilterTrait#RegexSCMSourceFilterTrait(String)}.
 * @deprecated use {@link RegexSCMSourceFilterTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setPattern(String pattern) {
    for (int i = 0; i < traits.size(); i++) {
        SCMTrait<?> trait = traits.get(i);
        if (trait instanceof RegexSCMSourceFilterTrait) {
            if (".*".equals(pattern)) {
                traits.remove(i);
            } else {
                traits.set(i, new RegexSCMSourceFilterTrait(pattern));
            }
            return;
        }
    }
    if (!".*".equals(pattern)) {
        traits.add(new RegexSCMSourceFilterTrait(pattern));
    }
}
 
Example #18
Source File: KubernetesFolderProperty.java    From kubernetes-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Called from Jelly.
 * 
 * @return
 */
@SuppressWarnings("unused") // Used by jelly
@Restricted(DoNotUse.class) // Used by jelly
public List<UsagePermission> getEffectivePermissions() {
    List<UsagePermission> ps = buildPermissions();

    Set<String> inheritedClouds = getInheritedClouds();

    for (UsagePermission p : ps) {
        if (inheritedClouds.contains(p.name)) {
            p.setGranted(true);
            p.setInherited(true);
        }

        if (getPermittedClouds().contains(p.name)) {
            p.setGranted(true);
        }
    }

    // a non-admin User is only allowed to see granted clouds
    if (!userHasAdministerPermission()) {
        ps = ps.stream().filter(UsagePermission::isGranted).collect(Collectors.toList());
    }

    return ps;
}
 
Example #19
Source File: GitHubSCMSource.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public boolean getBuildOriginBranch() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof BranchDiscoveryTrait) {
            return ((BranchDiscoveryTrait) trait).isBuildBranch();
        }
    }
    return false;
}
 
Example #20
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Legacy getter.
 *
 * @return {@link RegexSCMSourceFilterTrait#getRegex()}.
 * @deprecated use {@link RegexSCMSourceFilterTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public String getPattern() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof RegexSCMSourceFilterTrait) {
            return ((RegexSCMSourceFilterTrait) trait).getRegex();
        }
    }
    return ".*";
}
 
Example #21
Source File: GerritSCMSource.java    From gerrit-code-review-plugin with Apache License 2.0 5 votes vote down vote up
@Restricted(DoNotUse.class)
@DataBoundSetter
public void setBrowser(GitRepositoryBrowser browser) {
  List<SCMSourceTrait> traits = new ArrayList<>(this.traits);
  for (Iterator<SCMSourceTrait> iterator = traits.iterator(); iterator.hasNext(); ) {
    if (iterator.next() instanceof GitBrowserSCMSourceTrait) {
      iterator.remove();
    }
  }
  if (browser != null) {
    traits.add(new GitBrowserSCMSourceTrait(browser));
  }
  setTraits(traits);
}
 
Example #22
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Legacy getter.
 *
 * @return {@link ForkPullRequestDiscoveryTrait#getStrategies()}.
 * @deprecated use {@link ForkPullRequestDiscoveryTrait#getStrategies()}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public boolean getBuildForkPRHead() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof ForkPullRequestDiscoveryTrait) {
            return ((ForkPullRequestDiscoveryTrait) trait).getStrategies()
                    .contains(ChangeRequestCheckoutStrategy.HEAD);
        }
    }
    return false;
}
 
Example #23
Source File: GerritSCMSource.java    From gerrit-code-review-plugin with Apache License 2.0 5 votes vote down vote up
@Restricted(DoNotUse.class)
@DataBoundSetter
public void setGitTool(String gitTool) {
  List<SCMSourceTrait> traits = new ArrayList<>(this.traits);
  gitTool = Util.fixEmptyAndTrim(gitTool);
  for (Iterator<SCMSourceTrait> iterator = traits.iterator(); iterator.hasNext(); ) {
    if (iterator.next() instanceof GitToolSCMSourceTrait) {
      iterator.remove();
    }
  }
  if (gitTool != null) {
    traits.add(new GitToolSCMSourceTrait(gitTool));
  }
  setTraits(traits);
}
 
Example #24
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Legacy getter.
 *
 * @return {@link ForkPullRequestDiscoveryTrait#getStrategies()}.
 * @deprecated use {@link ForkPullRequestDiscoveryTrait#getStrategies()}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public boolean getBuildForkPRMerge() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof ForkPullRequestDiscoveryTrait) {
            return ((ForkPullRequestDiscoveryTrait) trait).getStrategies()
                    .contains(ChangeRequestCheckoutStrategy.MERGE);
        }
    }
    return false;
}
 
Example #25
Source File: GerritSCMSource.java    From gerrit-code-review-plugin with Apache License 2.0 5 votes vote down vote up
@Restricted(DoNotUse.class)
@DataBoundSetter
public void setExtensions(@CheckForNull List<GitSCMExtension> extensions) {
  List<SCMSourceTrait> traits = new ArrayList<>(this.traits);
  for (Iterator<SCMSourceTrait> iterator = traits.iterator(); iterator.hasNext(); ) {
    if (iterator.next() instanceof GitSCMExtensionTrait) {
      iterator.remove();
    }
  }
  EXTENSIONS:
  for (GitSCMExtension extension : Util.fixNull(extensions)) {
    for (SCMSourceTraitDescriptor d : SCMSourceTrait.all()) {
      if (d instanceof GitSCMExtensionTraitDescriptor) {
        GitSCMExtensionTraitDescriptor descriptor = (GitSCMExtensionTraitDescriptor) d;
        if (descriptor.getExtensionClass().isInstance(extension)) {
          try {
            SCMSourceTrait trait = descriptor.convertToTrait(extension);
            if (trait != null) {
              traits.add(trait);
              continue EXTENSIONS;
            }
          } catch (UnsupportedOperationException e) {
            LOGGER.log(
                Level.WARNING,
                "Could not convert " + extension.getClass().getName() + " to a trait",
                e);
          }
        }
      }
      LOGGER.log(
          Level.FINE,
          "Could not convert {0} to a trait (likely because this option does not "
              + "make sense for a GitSCMSource)",
          extension.getClass().getName());
    }
  }
  setTraits(traits);
}
 
Example #26
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Legacy getter.
 *
 * @return {@link OriginPullRequestDiscoveryTrait#getStrategies()}.
 * @deprecated use {@link OriginPullRequestDiscoveryTrait#getStrategies()}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public boolean getBuildOriginPRHead() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof OriginPullRequestDiscoveryTrait) {
            return ((OriginPullRequestDiscoveryTrait) trait).getStrategies()
                    .contains(ChangeRequestCheckoutStrategy.HEAD);
        }
    }
    return false;

}
 
Example #27
Source File: GerritSCMSource.java    From gerrit-code-review-plugin with Apache License 2.0 5 votes vote down vote up
@Restricted(DoNotUse.class)
public String getRawRefSpecs() {
  String remoteName = null;
  RefSpecsSCMSourceTrait refSpecs = null;
  for (SCMSourceTrait trait : traits) {
    if (trait instanceof RemoteNameSCMSourceTrait) {
      remoteName = ((RemoteNameSCMSourceTrait) trait).getRemoteName();
      if (refSpecs != null) break;
    }
    if (trait instanceof RefSpecsSCMSourceTrait) {
      refSpecs = (RefSpecsSCMSourceTrait) trait;
      if (remoteName != null) break;
    }
  }
  if (remoteName == null) {
    remoteName = AbstractGitSCMSource.DEFAULT_REMOTE_NAME;
  }
  if (refSpecs == null) {
    return AbstractGitSCMSource.REF_SPEC_DEFAULT.replaceAll(
        AbstractGitSCMSource.REF_SPEC_REMOTE_NAME_PLACEHOLDER, remoteName);
  }
  StringBuilder result = new StringBuilder();
  boolean first = true;
  Pattern placeholder = Pattern.compile(AbstractGitSCMSource.REF_SPEC_REMOTE_NAME_PLACEHOLDER);
  for (String template : refSpecs.asStrings()) {
    if (first) {
      first = false;
    } else {
      result.append(' ');
    }
    result.append(placeholder.matcher(template).replaceAll(remoteName));
  }
  return result.toString();
}
 
Example #28
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Legacy getter.
 *
 * @return {@link OriginPullRequestDiscoveryTrait#getStrategies()}.
 * @deprecated use {@link OriginPullRequestDiscoveryTrait#getStrategies()}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public boolean getBuildOriginPRMerge() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof OriginPullRequestDiscoveryTrait) {
            return ((OriginPullRequestDiscoveryTrait) trait).getStrategies()
                    .contains(ChangeRequestCheckoutStrategy.MERGE);
        }
    }
    return false;
}
 
Example #29
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Legacy getter.
 *
 * @return {@link BranchDiscoveryTrait#isBuildBranchesWithPR()}.
 * @deprecated use {@link BranchDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public boolean getBuildOriginBranchWithPR() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof BranchDiscoveryTrait) {
            return ((BranchDiscoveryTrait) trait).isBuildBranchesWithPR();
        }
    }
    return false;
}
 
Example #30
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Legacy getter.
 * @return {@link BranchDiscoveryTrait#isBuildBranch()}.
 * @deprecated use {@link BranchDiscoveryTrait}
 */
@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
public boolean getBuildOriginBranch() {
    for (SCMTrait<?> trait : traits) {
        if (trait instanceof BranchDiscoveryTrait) {
            return ((BranchDiscoveryTrait) trait).isBuildBranch();
        }
    }
    return false;
}