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); }
public override void TearDown() { if (transport != null) { transport.Close(); transport = null; } base.TearDown(); }
/// <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); } }
/// <summary> /// Executes the /// <code>LsRemote</code> /// command with all the options and parameters /// collected by the setter methods (e.g. /// <see cref="SetHeads(bool)">SetHeads(bool)</see> /// ) of this /// class. Each instance of this class should only be used for one invocation /// of the command. Don't call this method twice on an instance. /// </summary> /// <returns>a collection of references in the remote repository</returns> /// <exception cref="NGit.Api.Errors.InvalidRemoteException">when called with an invalid remote uri /// </exception> /// <exception cref="NGit.Api.Errors.TransportException">for errors that occurs during transport /// </exception> /// <exception cref="NGit.Api.Errors.GitAPIException"></exception> public override ICollection <Ref> Call() { CheckCallable(); NGit.Transport.Transport transport = null; FetchConnection fc = null; try { transport = NGit.Transport.Transport.Open(repo, remote); transport.SetOptionUploadPack(uploadPack); Configure(transport); ICollection <RefSpec> refSpecs = new AList <RefSpec>(1); if (tags) { refSpecs.AddItem(new RefSpec("refs/tags/*:refs/remotes/origin/tags/*")); } if (heads) { refSpecs.AddItem(new RefSpec("refs/heads/*:refs/remotes/origin/*")); } ICollection <Ref> refs; IDictionary <string, Ref> refmap = new Dictionary <string, Ref>(); fc = transport.OpenFetch(); refs = fc.GetRefs(); if (refSpecs.IsEmpty()) { foreach (Ref r in refs) { refmap.Put(r.GetName(), r); } } else { foreach (Ref r_1 in refs) { foreach (RefSpec rs in refSpecs) { if (rs.MatchSource(r_1)) { refmap.Put(r_1.GetName(), r_1); break; } } } } return(refmap.Values); } catch (URISyntaxException) { throw new InvalidRemoteException(MessageFormat.Format(JGitText.Get().invalidRemote , remote)); } catch (NGit.Errors.NotSupportedException e) { throw new JGitInternalException(JGitText.Get().exceptionCaughtDuringExecutionOfLsRemoteCommand , e); } catch (NGit.Errors.TransportException e) { throw new NGit.Errors.TransportException(e.Message, e); } finally { if (fc != null) { fc.Close(); } if (transport != null) { transport.Close(); } } }