@Deprecated @Override @Restricted(DoNotUse.class) @RestrictedSince("3.4.0") protected List<RefSpec> getRefSpecs() { return new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(traits).asRefSpecs(); }
/** * {@inheritDoc} */ @Override protected boolean isCategoryEnabled(@NonNull SCMHeadCategory category) { if (category instanceof TagSCMHeadCategory) { return new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits()).wantTags(); } return super.isCategoryEnabled(category); }
if (new GiteaSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(source.getTraits()) .notificationsDisabled()) {
GitSCMSource git = (GitSCMSource) source; GitSCMSourceContext<?,?> ctx = new GitSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(git.getTraits()); if (ctx.ignoreOnPushNotifications()) {
GitHubSCMSourceContext context = new GitHubSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(src.getTraits()); if (context.wantBranches()) {
@Override public void afterSave() { WebhookRegistration mode = new GiteaSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(new GiteaSCMNavigatorContext().withTraits(traits).traits()) .webhookRegistration(); GiteaWebhookListener.register(getOwner(), this, mode, credentialsId); }
@Override public void afterSave(@NonNull SCMNavigatorOwner owner) { WebhookRegistration mode = new GiteaSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(new GiteaSCMNavigatorContext().withTraits(traits).traits()) .webhookRegistration(); GiteaWebhookListener.register(owner, this, mode, credentialsId); }
/** * {@inheritDoc} */ @NonNull @Override protected Set<String> retrieveRevisions(@NonNull final TaskListener listener) throws IOException, InterruptedException { final GitSCMSourceContext context = new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits()); return doRetrieve(new Retriever<Set<String>>() { @Override public Set<String> run(GitClient client, String remoteName) throws IOException, InterruptedException { Set<String> revisions = new HashSet<String>(); if (context.wantBranches()) { for (Branch branch : client.getRemoteBranches()) { revisions.add(branch.getName().replaceFirst( "^" + Pattern.quote(context.remoteName()) + "/", "" )); } } if (context.wantTags()) { revisions.addAll(client.getTagNames("*")); } return revisions; } }, context, listener, false); }
PullRequestSCMHead head = (PullRequestSCMHead) revision.getHead(); try (GitHubSCMSourceRequest request = new GitHubSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(traits) .newRequest(this, listener)) {
/** * {@inheritDoc} */ @CheckForNull @Override protected SCMRevision retrieve(@NonNull final String revision, @NonNull final TaskListener listener) throws IOException, InterruptedException { final GitSCMSourceContext context = new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits()); return doRetrieve(new Retriever<SCMRevision>() { @Override public SCMRevision run(GitClient client, String remoteName) throws IOException, InterruptedException { String hash; try { hash = client.revParse(revision).name(); } catch (GitException x) { // Try prepending remote name in case it was a branch. try { hash = client.revParse(context.remoteName() + "/" + revision).name(); } catch (GitException x2) { listener.getLogger().println(x.getMessage()); listener.getLogger().println(x2.getMessage()); return null; } } return new SCMRevisionImpl(new SCMHead(revision), hash); } }, context, listener, false); }
@Override public boolean isMatch(SCMSource source) { if (source instanceof GitSCMSource) { GitSCMSource git = (GitSCMSource) source; GitSCMSourceContext ctx = new GitSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(git.getTraits()); if (ctx.ignoreOnPushNotifications()) { return false; } URIish remote; try { remote = new URIish(git.getRemote()); } catch (URISyntaxException e) { // ignore return false; } if (GitStatus.looselyMatches(u, remote)) { notified[0] = true; return true; } return false; } return false; }
return; if (new GitHubSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(((GitHubSCMSource) source).getTraits()) .notificationsDisabled()) {
protected SCMRevision retrieve(@NonNull final SCMHead head, @NonNull TaskListener listener) throws IOException, InterruptedException { final GitSCMSourceContext context = new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits()); return doRetrieve(new Retriever<SCMRevision>() { @Override
GitHubSCMSourceContext context = new GitHubSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(src.getTraits()); if (!fork && context.wantBranches()) {
protected SCMRevision retrieve(@NonNull String thingName, @NonNull TaskListener listener) throws IOException, InterruptedException { try (MercurialSCMSourceRequest request = new MercurialSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(traits) .newRequest(this, listener)) {
new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits()), listener, false);
if (new GiteaSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(source.getTraits()) .notificationsDisabled()) {
GitSCMSource git = (GitSCMSource) source; GitSCMSourceContext<?, ?> ctx = new GitSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(git.getTraits()); if (ctx.ignoreOnPushNotifications()) {
public Map<SCMHead, SCMRevision> headsFor(GiteaSCMSource source) { Map<SCMHead, SCMRevision> result = new HashMap<>(); try (GiteaSCMSourceRequest request = new GiteaSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(source.getTraits()) .newRequest(source, null)) {
/** * Returns the GitHub Repository associated to a Job. * * @param job A {@link Job} * @return A {@link GHRepository} or {@code null}, if any of: a credentials was not provided; notifications were * disabled, or the job is not from a {@link GitHubSCMSource}. * @throws IOException */ @CheckForNull private static GitHub lookUpGitHub(@NonNull Job<?,?> job) throws IOException { SCMSource src = SCMSource.SourceByItem.findSource(job); if (src instanceof GitHubSCMSource) { GitHubSCMSource source = (GitHubSCMSource) src; if (new GitHubSCMSourceContext(null, SCMHeadObserver.none()) .withTraits(source.getTraits()) .notificationsDisabled()) { return null; } if (source.getScanCredentialsId() != null) { return Connector.connect(source.getApiUri(), Connector.lookupScanCredentials (job, source.getApiUri(), source.getScanCredentialsId())); } } return null; }