List of usage examples for org.eclipse.jgit.transport RefSpec matchSource
public boolean matchSource(Ref r)
From source file:com.google.gerrit.common.data.SubscribeSection.java
License:Apache License
/** * Determines if the <code>branch</code> could trigger a * superproject update as allowed via this subscribe section. * * @param branch the branch to check//from w ww. j a v a2 s . co m * @return if the branch could trigger a superproject update */ public boolean appliesTo(Branch.NameKey branch) { for (RefSpec r : refSpecs) { if (r.matchSource(branch.get())) { return true; } } return false; }
From source file:com.google.gerrit.server.git.PushOp.java
License:Apache License
private RefSpec matchSrc(final String ref) { for (final RefSpec s : config.getPushRefSpecs()) { if (s.matchSource(ref)) { return s.expandFromSource(ref); }/* ww w .ja va 2 s.c om*/ } return null; }
From source file:com.googlesource.gerrit.plugins.replication.Destination.java
License:Apache License
boolean wouldPushRef(String ref) { if (!config.replicatePermissions() && RefNames.REFS_CONFIG.equals(ref)) { return false; }//from w w w . j a v a2s . c o m for (RefSpec s : config.getRemoteConfig().getPushRefSpecs()) { if (s.matchSource(ref)) { return true; } } return false; }
From source file:com.googlesource.gerrit.plugins.replication.PushOne.java
License:Apache License
private RefSpec matchSrc(String ref) { for (RefSpec s : config.getPushRefSpecs()) { if (s.matchSource(ref)) { return s.expandFromSource(ref); }/*from w ww . j a v a2s . c o m*/ } return null; }
From source file:org.eclipse.egit.core.internal.gerrit.GerritUtil.java
License:Open Source License
/** * Configure fetching review summary notes * * @param remoteConfig//from ww w. jav a 2 s .co m * the remote configuration to configure this in * @return {@code true} if the {@code remoteConfig} was changed, * {@code false} otherwise. */ public static boolean configureFetchNotes(RemoteConfig remoteConfig) { String notesRef = Constants.R_NOTES + "*"; //$NON-NLS-1$ List<RefSpec> fetchRefSpecs = remoteConfig.getFetchRefSpecs(); for (RefSpec refSpec : fetchRefSpecs) { if (refSpec.matchSource(notesRef)) { return false; } } remoteConfig.addFetchRefSpec(new RefSpec(notesRef + ':' + notesRef)); return true; }
From source file:org.eclipse.egit.core.op.CloneOperation.java
License:Open Source License
private void doInit(final IProgressMonitor monitor) throws URISyntaxException, IOException { monitor.setTaskName(CoreText.CloneOperation_initializingRepository); local = new FileRepository(gitdir); local.create();/*from w w w. ja v a 2s . co m*/ final RefUpdate head = local.updateRef(Constants.HEAD); head.disableRefLog(); head.link(branch); remoteConfig = new RemoteConfig(local.getConfig(), remoteName); remoteConfig.addURI(uri); final String dst = Constants.R_REMOTES + remoteConfig.getName(); RefSpec wcrs = new RefSpec(); wcrs = wcrs.setForceUpdate(true); wcrs = wcrs.setSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ if (allSelected) { remoteConfig.addFetchRefSpec(wcrs); } else { for (final Ref ref : selectedBranches) if (wcrs.matchSource(ref)) remoteConfig.addFetchRefSpec(wcrs.expandFromSource(ref)); } // we're setting up for a clone with a checkout local.getConfig().setBoolean("core", null, "bare", false); //$NON-NLS-1$ //$NON-NLS-2$ remoteConfig.update(local.getConfig()); // branch is like 'Constants.R_HEADS + branchName', we need only // the 'branchName' part String branchName = branch.substring(Constants.R_HEADS.length()); // setup the default remote branch for branchName local.getConfig().setString("branch", branchName, "remote", remoteName); //$NON-NLS-1$ //$NON-NLS-2$ local.getConfig().setString("branch", branchName, "merge", branch); //$NON-NLS-1$ //$NON-NLS-2$ local.getConfig().save(); }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private void tryAutoCompleteSrcToDst() { final String src = creationSrcCombo.getText(); final String dst = creationDstCombo.getText(); if (src == null || src.length() == 0) return;/* w w w .ja v a 2 s . c om*/ if (dst != null && dst.length() > 0) { // dst is already there, just fix wildcards if needed final String newDst; if (RefSpec.isWildcard(src)) newDst = wildcardSpecComponent(dst); else newDst = unwildcardSpecComponent(dst, src); creationDstCombo.setText(newDst); return; } if (!isValidRefExpression(src)) { // no way to be smarter than user here return; } // dst is empty, src is ref or wildcard, so we can rewrite it as user // would perhaps if (pushSpecs) creationDstCombo.setText(src); else { for (final RefSpec spec : predefinedConfigured) { if (spec.matchSource(src)) { final String newDst = spec.expandFromSource(src).getDestination(); creationDstCombo.setText(newDst); return; } } if (remoteName != null && src.startsWith(Constants.R_HEADS)) { final String newDst = Constants.R_REMOTES + remoteName + '/' + src.substring(Constants.R_HEADS.length()); creationDstCombo.setText(newDst); } } }
From source file:org.eclipse.egit.ui.internal.components.RefSpecPanel.java
License:Open Source License
private void validateSpecsCrossDst() { final Map<String, RefSpec> dstsSpecsMap = new HashMap<String, RefSpec>(); try {//ww w . java 2 s . c o m for (final RefSpec spec : specs) { if (!spec.isWildcard()) { if (!tryAddDestination(dstsSpecsMap, spec.getDestination(), spec)) return; } else { final Collection<String> srcNames; if (pushSpecs) srcNames = localRefNames; else srcNames = remoteRefNames; for (final String src : srcNames) { if (spec.matchSource(src)) { final String dst = spec.expandFromSource(src).getDestination(); if (!tryAddDestination(dstsSpecsMap, dst, spec)) return; } } } } } finally { matchingAnyRefs = !dstsSpecsMap.isEmpty(); } }
From source file:org.eclipse.egit.ui.internal.gerrit.ConfigureGerritWizard.java
License:Open Source License
private void configureFetchNotes() { String notesRef = Constants.R_NOTES + "*"; //$NON-NLS-1$ List<RefSpec> fetchRefSpecs = remoteConfig.getFetchRefSpecs(); for (RefSpec refSpec : fetchRefSpecs) { if (refSpec.matchSource(notesRef)) return; }//from w w w. ja v a2 s. c om remoteConfig.addFetchRefSpec(new RefSpec(notesRef + ":" + notesRef)); //$NON-NLS-1$ }