@Deprecated @Override @Restricted(DoNotUse.class) @RestrictedSince("3.4.0") protected List<RefSpec> getRefSpecs() { return new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(traits).asRefSpecs(); }
/** * Constructor. * * @param source the source. * @param context the context. * @param listener the (optional) {@link TaskListener}. */ public GitSCMSourceRequest(@NonNull SCMSource source, @NonNull GitSCMSourceContext<?, ?> context, TaskListener listener) { super(source, context, listener); fetchBranches = context.wantBranches(); fetchTags = context.wantTags(); remoteName = context.remoteName(); gitTool = context.gitTool(); refSpecs = Collections.unmodifiableList(context.asRefSpecs()); }
@Override public Void run(GitClient client, String remoteName) throws IOException, InterruptedException { final Repository repository = client.getRepository(); try (RevWalk walk = new RevWalk(repository); GitSCMSourceRequest request = context.newRequest(AbstractGitSCMSource.this, listener)) { Map<String, ObjectId> remoteReferences = null; if (context.wantBranches() || context.wantTags()) { listener.getLogger().println("Listing remote references..."); remoteReferences = client.getRemoteReferences( client.getRemoteUrl(remoteName), null, context.wantBranches(), context.wantTags() ); } if (context.wantBranches()) { discoverBranches(repository, walk, request, remoteReferences); } if (context.wantTags()) { discoverTags(repository, walk, request, remoteReferences); } } return null; }
/** * {@inheritDoc} */ @Override protected void decorateContext(SCMSourceContext<?, ?> context) { GitSCMSourceContext<?,?> ctx = (GitSCMSourceContext<?, ?>) context; ctx.wantBranches(true); ctx.withAuthority(new BranchSCMHeadAuthority()); }
/** * {@inheritDoc} */ @Override protected void decorateContext(SCMSourceContext<?, ?> context) { GitSCMSourceContext<?,?> ctx = (GitSCMSourceContext<?, ?>) context; ctx.wantTags(true); ctx.withAuthority(new TagSCMHeadAuthority()); }
GitSCMSource git = (GitSCMSource) source; GitSCMSourceContext<?,?> ctx = new GitSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(git.getTraits()); if (ctx.ignoreOnPushNotifications()) { return Collections.emptyMap(); for (SCMHeadPrefilter filter: ctx.prefilters()) { if (filter.isExcluded(git, head)) { return Collections.emptyMap();
/** * {@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); }
@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; }
@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; } },
/** * {@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); }
File cacheDir = getCacheDir(cacheEntry); Git git = Git.with(listener, new EnvVars(EnvVars.masterEnvVars)).in(cacheDir); GitTool tool = resolveGitTool(context.gitTool()); if (tool != null) { git.using(tool.getGitExe()); client.init(); String remoteName = context.remoteName(); listener.getLogger().println("Setting " + remoteName + " to " + getRemote()); client.setRemoteUrl(remoteName, getRemote()); listener.getLogger().println("URI syntax exception for '" + remoteName + "' " + ex); fetch.from(remoteURI, context.asRefSpecs()).execute(); return retriever.run(client, remoteName); } finally {
/** * Converts the ref spec templates into {@link RefSpec} instances. * * @return the list of {@link RefSpec} instances. */ @NonNull public final List<RefSpec> asRefSpecs() { List<RefSpec> result = new ArrayList<>(Math.max(refSpecs.size(), 1)); for (String template : refSpecs()) { result.add(new RefSpec( template.replaceAll(AbstractGitSCMSource.REF_SPEC_REMOTE_NAME_PLACEHOLDER, remoteName()) )); } return result; }
@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); } },
/** * {@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); }
GitSCMSource git = (GitSCMSource) source; GitSCMSourceContext ctx = new GitSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(git.getTraits()); if (ctx.ignoreOnPushNotifications()) { GitSCMSource git = (GitSCMSource) source; GitSCMSourceContext<?,?> ctx = new GitSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(git.getTraits()); if (ctx.ignoreOnPushNotifications()) { GitSCMSource git = (GitSCMSource) source; GitSCMSourceContext<?, ?> ctx = new GitSCMSourceContext<>(null, SCMHeadObserver.none()) .withTraits(git.getTraits()); if (ctx.ignoreOnPushNotifications()) { continue;
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
new GitSCMSourceContext<>(null, SCMHeadObserver.none()).withTraits(getTraits()), listener, false);
throws IOException, InterruptedException { final GitSCMSourceContext context = new GitSCMSourceContext<>(criteria, observer).withTraits(getTraits()); doRetrieve(new Retriever<Void>() { @Override