public override void SetUp() { base.SetUp(); src = CreateBareRepository(); dst = CreateBareRepository(); // Fill dst with a some common history. // TestRepository d = new TestRepository <Repository>(dst); a = d.Blob("a"); A = d.Commit(d.Tree(d.File("a", a))); B = d.Commit().Parent(A).Create(); d.Update(R_MASTER, B); // Clone from dst into src // NGit.Transport.Transport t = NGit.Transport.Transport.Open(src, UriOf(dst)); try { t.Fetch(PM, Collections.Singleton(new RefSpec("+refs/*:refs/*"))); NUnit.Framework.Assert.AreEqual(B, src.Resolve(R_MASTER)); } finally { t.Close(); } // Now put private stuff into dst. // b = d.Blob("b"); P = d.Commit(d.Tree(d.File("b", b)), A); d.Update(R_PRIVATE, P); }
/// <summary> /// Executes the /// <code>fetch</code> /// command with all the options and parameters /// collected by the setter methods of this class. Each instance of this /// class should only be used for one invocation of the command (means: one /// call to /// <see cref="Call()">Call()</see> /// ) /// </summary> /// <returns> /// a /// <see cref="NGit.Transport.FetchResult">NGit.Transport.FetchResult</see> /// object representing the successful fetch /// result /// </returns> /// <exception cref="NGit.Api.Errors.InvalidRemoteException">when called with an invalid remote uri /// </exception> /// <exception cref="NGit.Api.Errors.JGitInternalException"> /// a low-level exception of JGit has occurred. The original /// exception can be retrieved by calling /// <see cref="System.Exception.InnerException()">System.Exception.InnerException()</see> /// . /// </exception> public override FetchResult Call() { CheckCallable(); try { NGit.Transport.Transport transport = NGit.Transport.Transport.Open(repo, remote); try { transport.SetCheckFetchedObjects(checkFetchedObjects); transport.SetRemoveDeletedRefs(removeDeletedRefs); transport.SetTimeout(timeout); transport.SetDryRun(dryRun); if (tagOption != null) { transport.SetTagOpt(tagOption); } transport.SetFetchThin(thin); if (credentialsProvider != null) { transport.SetCredentialsProvider(credentialsProvider); } FetchResult result = transport.Fetch(monitor, refSpecs); return(result); } finally { transport.Close(); } } catch (NoRemoteRepositoryException e) { throw new InvalidRemoteException(MessageFormat.Format(JGitText.Get().invalidRemote , remote), e); } catch (TransportException e) { throw new JGitInternalException(JGitText.Get().exceptionCaughtDuringExecutionOfFetchCommand , e); } catch (URISyntaxException) { throw new InvalidRemoteException(MessageFormat.Format(JGitText.Get().invalidRemote , remote)); } catch (NotSupportedException e) { throw new JGitInternalException(JGitText.Get().exceptionCaughtDuringExecutionOfFetchCommand , e); } }