Refine search
protected FetchResult fetch(Git git, String label) { FetchCommand fetch = git.fetch(); fetch.setRemote("origin"); fetch.setTagOpt(TagOpt.FETCH_TAGS); fetch.setRemoveDeletedRefs(deleteUntrackedBranches); if (this.refreshRate > 0) { this.setLastRefresh(System.currentTimeMillis()); } configureCommand(fetch); try { FetchResult result = fetch.call(); if (result.getTrackingRefUpdates() != null && result.getTrackingRefUpdates().size() > 0) { logger.info("Fetched for remote " + label + " and found " + result.getTrackingRefUpdates().size() + " updates"); } return result; } catch (Exception ex) { String message = "Could not fetch remote for " + label + " remote: " + git .getRepository().getConfig().getString("remote", "origin", "url"); warn(message, ex); return null; } }
/** * fetch tags from remote * @param path * @param remoteName * @return * @throws GitException */ public static Path fetchTags(Path path, String remoteName) throws GitException { try (Git git = Git.open(path.toFile())) { git.fetch() .setRemote(remoteName) .setRefSpecs(new RefSpec("refs/tags/*:refs/tags/*")) .setTagOpt(TagOpt.FETCH_TAGS) .call(); } catch (Throwable throwable) { throw new GitException("fetch tags error", throwable); } return path; }
ObjectId oldHeadTree = git.getRepository().resolve(this.lastProcessedGitHash + "^{tree}"); this.git.fetch() .setRemote(REMOTE_NAME) .setCredentialsProvider(getCredentialsProvider()) .setTransportConfigCallback(buildTransportConfigCallback()) .call(); this.git.reset().setMode(ResetCommand.ResetType.HARD).setRef(REMOTE_NAME + "/" + this.branchName).call(); ObjectId head = this.git.getRepository().resolve("HEAD");
@Signature public Memory fetch(ArrayMemory settings) throws GitAPIException { FetchCommand command = getWrappedObject().fetch(); command.setTransportConfigCallback(transportConfigCallback); if (credentialsProvider != null) { command.setCredentialsProvider(credentialsProvider); command.setCheckFetchedObjects(settings.valueOfIndex("checkFetchedObjects").toBoolean()); command.setDryRun(settings.valueOfIndex("dryRun").toBoolean()); command.setRemoveDeletedRefs(settings.valueOfIndex("removeDeletedRefs").toBoolean()); command.setThin(settings.valueOfIndex("thin").toBoolean()); command.setRemote(remote.toString()); command.setRecurseSubmodules(SubmoduleConfig.FetchRecurseSubmodulesMode.valueOf(recurseSubmodules.toString())); command.setTagOpt(TagOpt.valueOf(tagOpt.toString())); command.setTimeout(timeout.toInteger()); command.setCredentialsProvider(new UsernamePasswordCredentialsProvider( credentials.valueOfIndex("username").toString(), credentials.valueOfIndex("password").toString() FetchResult call = command.call(); return GitUtils.valueOf(call);
@Override public synchronized PushPolicyResult doPush(GitContext context, CredentialsProvider credentialsProvider) { StoredConfig config = git.getRepository().getConfig(); String remoteUrl = config.getString("remote", remoteRef, "url"); if (remoteUrl == null) { Exception lastException = null; try { resit = git.push().setTimeout(gitTimeout).setCredentialsProvider(credentialsProvider).setPushAll().call().iterator(); } catch (GitAPIException | JGitInternalException ex) { lastException = ex; try { GitHelpers.checkoutBranch(git, branch); FetchResult fetchResult = git.fetch().setTimeout(gitTimeout).setCredentialsProvider(credentialsProvider).setRemote(remoteRef).setRefSpecs(new RefSpec("refs/heads/" + branch)).call(); Ref fetchRef = fetchResult.getAdvertisedRef("refs/heads/" + branch); git.branchRename().setOldName(branch).setNewName(branch + "-tmp").call();
CloneCommand command = Git.cloneRepository().setURI( repository.getFetchUrl() ); command.setCredentialsProvider( credentials ).setBranch( branch ).setDirectory( fileSet.getBasedir() ); command.setProgressMonitor( monitor ); git = Git.open( fileSet.getBasedir() ); git.fetch().setCredentialsProvider( credentials ).setProgressMonitor( monitor ).call();
RefSpec masterSpec = new RefSpec("+" + Constants.R_HEADS + gfConfig.getMaster() + ":" + Constants.R_REMOTES + "origin/" + gfConfig.getMaster()); git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(masterSpec).call(); git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).setRefSpecs(developSpec).call(); git.fetch().setRemote(Constants.DEFAULT_REMOTE_NAME).call();
@Override public synchronized PullPolicyResult doPull(GitContext context, CredentialsProvider credentialsProvider, boolean allowVersionDelete, boolean allowPush, int timeoutInSeconds) { Repository repository = git.getRepository(); StoredConfig config = repository.getConfig(); String remoteUrl = config.getString("remote", remoteRef, "url"); for (Ref ref : git.lsRemote().setTimeout(timeoutInSeconds).setCredentialsProvider(credentialsProvider) .setTags(false) .setHeads(true) git.fetch().setTimeout(timeoutInSeconds).setCredentialsProvider(credentialsProvider) .setTagOpt(TagOpt.FETCH_TAGS) .setRemote(remoteRef).call(); } catch (Exception ex) { lastException = ex;
File flowDir = new File(git.getRepository().getDirectory(), JGitFlowConstants.GITFLOW_DIR); File mergeBase = new File(flowDir, JGitFlowConstants.MERGE_BASE); git.fetch().setRefSpecs(branchSpec).call(); git.fetch().setRefSpecs(developSpec).call();
private void fetch(String branchName) throws GitAPIException { logger.info("Fetching branch " + branchName); if (!branchName.startsWith(REFS_REMOTES)) { throw new IllegalArgumentException("Branch name '" + branchName + "' is not tracking branch name since it does not start " + REFS_REMOTES); } String remoteName = extractRemoteName(branchName); String shortName = extractShortName(remoteName, branchName); git.fetch().setRemote(remoteName).setRefSpecs(new RefSpec(REFS_HEADS + shortName + ":" + branchName)).call(); }
@Override public Git cloneRepository(Git git, boolean fetchAndCheckout) throws GitAPIException, IOException { File tmpLocation = new File(tmpPatchManagement, TS.format(new Date())); Git fork = Git.init().setBare(false) .setGitDir(new File(tmpLocation, Constants.DOT_GIT)) .setDirectory(tmpLocation).call(); StoredConfig config = fork.getRepository().getConfig(); config.setString("remote", "origin", "url", git.getRepository().getDirectory().getCanonicalPath()); config.setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*"); config.save(); if (fetchAndCheckout) { fork.fetch() .setRemote("origin") .setTagOpt(TagOpt.FETCH_TAGS) .call(); fork.checkout() .setCreateBranch(true) .setName(getMainBranchName()) .setUpstreamMode(CreateBranchCommand.SetupUpstreamMode.TRACK) .setStartPoint("origin/" + getMainBranchName()) .call(); } return fork; }
if (RepositoryCache.FileKey.resolve(local, FS.DETECTED) != null) { log.info("Reuse existing local repository " + local); try (Repository repository = Git.open(local).getRepository()) { String remoteUrl = repository.getConfig() .getString(ConfigConstants.CONFIG_REMOTE_SECTION, CloneCommand cloneCommand = Git.cloneRepository() .setURI(uri) .setDirectory(local) FetchCommand fetchCommand = git.fetch(); if (StringUtils.isNotBlank(login)) { fetchCommand.setCredentialsProvider(new UsernamePasswordCredentialsProvider(login, password)); fetchCommand.call(); boolean branchExists = git.getRepository().findRef(branch) != null;
try (Git git = Git.cloneRepository() .setURI(REMOTE_URL) .setDirectory(localPath) .call()) { System.out.println("Having repository: " + git.getRepository().getDirectory()); FetchResult result = git.fetch().setCheckFetchedObjects(true).call(); System.out.println("Messages: " + result.getMessages());
final FetchCommand fetch = git.fetch(); final String refName = Constants.R_HEADS + remoteBranch(); final FetchResult fetchResult = fetch.setRefSpecs(new RefSpec(refName)) .setCheckFetchedObjects(true) .setRemoveDeletedRefs(true) .setTagOpt(TagOpt.NO_TAGS) .setTimeout(GIT_TIMEOUT_SECS) .call(); final RefUpdate refUpdate = git.getRepository().updateRef(refName); refUpdate.setNewObjectId(id); refUpdate.update(); try (ObjectReader reader = git.getRepository().newObjectReader(); TreeWalk treeWalk = new TreeWalk(reader); RevWalk revWalk = new RevWalk(reader)) {
callback.cloningSubmodule(generator.getPath()); CloneCommand clone = Git.cloneRepository(); configure(clone); clone.setURI(url); clone.setProgressMonitor(monitor); repository = clone.call().getRepository(); } else if (this.fetch) { if (fetchCallback != null) { fetchCallback.fetchingSubmodule(generator.getPath()); FetchCommand fetchCommand = Git.wrap(repository).fetch(); if (monitor != null) { fetchCommand.setProgressMonitor(monitor); fetchCommand.call();
@Override public synchronized PullPolicyResult doPull(GitContext context, CredentialsProvider credentialsProvider, boolean allowVersionDelete) { Repository repository = git.getRepository(); StoredConfig config = repository.getConfig(); String remoteUrl = config.getString("remote", remoteRef, "url"); git.fetch().setTimeout(gitTimeout).setCredentialsProvider(credentialsProvider).setRemote(remoteRef).call(); } catch (GitAPIException | JGitInternalException ex) { lastException = ex; try { for (Ref ref : git.branchList().setListMode(ListBranchCommand.ListMode.ALL).call()) {
@Override public FetchResult fetch(final Git git, final String remote, final String refSpec, final int timeout, final boolean fsck, final boolean dryRun, final boolean thin, final boolean prune) throws GitAPIException { FetchCommand fetch = git.fetch(); fetch.setCheckFetchedObjects(fsck); fetch.setRemoveDeletedRefs(prune); if (refSpec != null) fetch.setRefSpecs(new RefSpec(refSpec)); if (timeout >= 0) fetch.setTimeout(timeout); fetch.setDryRun(dryRun); fetch.setRemote(remote); fetch.setThin(thin); fetch.setProgressMonitor(new TextProgressMonitor()); FetchResult result = fetch.call(); return result; }
Set<String> removedFiles = git.clean().setCleanDirectories(true).call(); for (String removedFile : removedFiles) { log.debug("srcdeps: Removed an unstaged file [{}]", removedFile); git.reset().setMode(ResetType.HARD).call(); final String startPoint; final String refToFetch; final FetchCommand fetch = git.fetch().setRemote(remoteAlias); switch (srcVersion.getWellKnownType()) { case branch: refToFetch = "refs/heads/" + scmVersion; fetch.setRefSpecs( new RefSpec("+refs/heads/" + scmVersion + ":refs/remotes/" + remoteAlias + "/" + scmVersion)); startPoint = remoteAlias + "/" + scmVersion; case tag: refToFetch = "refs/tags/" + scmVersion; fetch.setRefSpecs(new RefSpec(refToFetch)); startPoint = scmVersion; break; + srcVersion.getWellKnownType() + "'."); FetchResult fetchResult = fetch.call();
String remoteBranchPath = Utils.getCompleteGithubRepoUrl(prInformation.getOtherRepo().getFullName()); RemoteAddCommand remoteBranchCommand = git.remoteAdd(); remoteBranchCommand.setName("PR"); remoteBranchCommand.setUri(new URIish(remoteBranchPath)); remoteBranchCommand.call(); git.fetch().setRemote("PR").call(); this.gitResetPaths(commitHeadSha, paths, git.getRepository().getDirectory().getParentFile()); git.commit().setMessage("Undo changes on source code").setAuthor(this.getCommitterIdent()).setCommitter(this.getCommitterIdent()).call(); } else {