/// <exception cref="Sharpen.URISyntaxException"></exception> /// <exception cref="NGit.Api.Errors.JGitInternalException"></exception> /// <exception cref="NGit.Api.Errors.InvalidRemoteException"></exception> /// <exception cref="System.IO.IOException"></exception> private FetchResult Fetch(Repository repo, URIish u) { // create the remote config and save it RemoteConfig config = new RemoteConfig(repo.GetConfig(), remote); config.AddURI(u); string dst = bare ? Constants.R_HEADS : Constants.R_REMOTES + config.Name; RefSpec refSpec = new RefSpec(); refSpec = refSpec.SetForceUpdate(true); refSpec = refSpec.SetSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ config.AddFetchRefSpec(refSpec); config.Update(repo.GetConfig()); repo.GetConfig().Save(); // run the fetch command FetchCommand command = new FetchCommand(repo); command.SetRemote(remote); command.SetProgressMonitor(monitor); command.SetTagOpt(TagOpt.FETCH_TAGS); command.SetTimeout(timeout); if (credentialsProvider != null) { command.SetCredentialsProvider(credentialsProvider); } IList <RefSpec> specs = CalculateRefSpecs(dst); command.SetRefSpecs(specs); return(command.Call()); }
/// <exception cref="Sharpen.URISyntaxException"></exception> /// <exception cref="NGit.Api.Errors.JGitInternalException"></exception> /// <exception cref="NGit.Api.Errors.InvalidRemoteException"></exception> /// <exception cref="System.IO.IOException"></exception> private FetchResult Fetch(Repository repo, URIish u) { // create the remote config and save it RemoteConfig config = new RemoteConfig(repo.GetConfig(), remote); config.AddURI(u); string dst = Constants.R_REMOTES + config.Name; RefSpec refSpec = new RefSpec(); refSpec = refSpec.SetForceUpdate(true); refSpec = refSpec.SetSourceDestination(Constants.R_HEADS + "*", dst + "/*"); //$NON-NLS-1$ //$NON-NLS-2$ config.AddFetchRefSpec(refSpec); config.Update(repo.GetConfig()); repo.GetConfig().SetString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants .CONFIG_KEY_REMOTE, remote); repo.GetConfig().SetString(ConfigConstants.CONFIG_BRANCH_SECTION, branch, ConfigConstants .CONFIG_KEY_MERGE, branch); repo.GetConfig().Save(); // run the fetch command FetchCommand command = new FetchCommand(repo); command.SetRemote(remote); command.SetProgressMonitor(monitor); command.SetTagOpt(TagOpt.FETCH_TAGS); if (credentialsProvider != null) { command.SetCredentialsProvider(credentialsProvider); } return(command.Call()); }