Beispiel #1
0
        public virtual void TestFindRemoteRefUpdatesTwoRefSpecs()
        {
            transport = NGit.Transport.Transport.Open(db, remoteConfig);
            RefSpec specA = new RefSpec("+refs/heads/a:refs/heads/b");
            RefSpec specC = new RefSpec("+refs/heads/c:refs/heads/d");
            ICollection <RefSpec>         specs  = Arrays.AsList(specA, specC);
            ICollection <RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(specs);

            NUnit.Framework.Assert.AreEqual(2, result.Count);
            bool foundA = false;
            bool foundC = false;

            foreach (RemoteRefUpdate rru in result)
            {
                if ("refs/heads/a".Equals(rru.GetSrcRef()) && "refs/heads/b".Equals(rru.GetRemoteName
                                                                                        ()))
                {
                    foundA = true;
                }
                if ("refs/heads/c".Equals(rru.GetSrcRef()) && "refs/heads/d".Equals(rru.GetRemoteName
                                                                                        ()))
                {
                    foundC = true;
                }
            }
            NUnit.Framework.Assert.IsTrue(foundA);
            NUnit.Framework.Assert.IsTrue(foundC);
        }
Beispiel #2
0
        public virtual void TestFindRemoteRefUpdatesWildcardNoTracking()
        {
            transport = NGit.Transport.Transport.Open(db, remoteConfig);
            ICollection <RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Sharpen.Collections
                                                                                     .NCopies(1, new RefSpec("+refs/heads/*:refs/heads/test/*")));

            NUnit.Framework.Assert.AreEqual(12, result.Count);
            bool foundA = false;
            bool foundB = false;

            foreach (RemoteRefUpdate rru in result)
            {
                if ("refs/heads/a".Equals(rru.GetSrcRef()) && "refs/heads/test/a".Equals(rru.GetRemoteName
                                                                                             ()))
                {
                    foundA = true;
                }
                if ("refs/heads/b".Equals(rru.GetSrcRef()) && "refs/heads/test/b".Equals(rru.GetRemoteName
                                                                                             ()))
                {
                    foundB = true;
                }
            }
            NUnit.Framework.Assert.IsTrue(foundA);
            NUnit.Framework.Assert.IsTrue(foundB);
        }
Beispiel #3
0
 internal WalkFetchConnection(WalkTransport t, WalkRemoteObjectDatabase w)
 {
     NGit.Transport.Transport wt = (NGit.Transport.Transport)t;
     local    = wt.local;
     objCheck = wt.IsCheckFetchedObjects() ? new ObjectChecker() : null;
     inserter = local.NewObjectInserter();
     reader   = local.NewObjectReader();
     remotes  = new AList <WalkRemoteObjectDatabase>();
     remotes.AddItem(w);
     unfetchedPacks  = new List <WalkFetchConnection.RemotePack>();
     packsConsidered = new HashSet <string>();
     noPacksYet      = new List <WalkRemoteObjectDatabase>();
     noPacksYet.AddItem(w);
     noAlternatesYet = new List <WalkRemoteObjectDatabase>();
     noAlternatesYet.AddItem(w);
     fetchErrors = new Dictionary <ObjectId, IList <Exception> >();
     packLocks   = new AList <PackLock>(4);
     revWalk     = new RevWalk(reader);
     revWalk.SetRetainBody(false);
     treeWalk         = new TreeWalk(reader);
     COMPLETE         = revWalk.NewFlag("COMPLETE");
     IN_WORK_QUEUE    = revWalk.NewFlag("IN_WORK_QUEUE");
     LOCALLY_SEEN     = revWalk.NewFlag("LOCALLY_SEEN");
     localCommitQueue = new DateRevQueue();
     workQueue        = new List <ObjectId>();
 }
        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);
        }
Beispiel #5
0
 public override void SetUp()
 {
     base.SetUp();
     Config config = ((FileBasedConfig)db.GetConfig());
     remoteConfig = new RemoteConfig(config, "test");
     remoteConfig.AddURI(new URIish("http://everyones.loves.git/u/2"));
     transport = null;
 }
 internal WalkPushConnection(WalkTransport walkTransport, WalkRemoteObjectDatabase
                             w)
 {
     transport = (NGit.Transport.Transport)walkTransport;
     local     = transport.local;
     uri       = transport.GetURI();
     dest      = w;
 }
Beispiel #7
0
		public override void TearDown()
		{
			if (transport != null)
			{
				transport.Close();
				transport = null;
			}
			base.TearDown();
		}
Beispiel #8
0
 public override void TearDown()
 {
     if (transport != null)
     {
         transport.Close();
         transport = null;
     }
     base.TearDown();
 }
Beispiel #9
0
        public override void SetUp()
        {
            base.SetUp();
            Config config = ((FileBasedConfig)db.GetConfig());

            remoteConfig = new RemoteConfig(config, "test");
            remoteConfig.AddURI(new URIish("http://everyones.loves.git/u/2"));
            transport = null;
        }
Beispiel #10
0
        public virtual void TestLocalTransportWithRelativePath()
        {
            FileRepository other    = CreateWorkRepository();
            string         otherDir = other.WorkTree.GetName();
            RemoteConfig   config   = new RemoteConfig(((FileBasedConfig)db.GetConfig()), "other"
                                                       );

            config.AddURI(new URIish("../" + otherDir));
            // Should not throw NoRemoteRepositoryException
            transport = NGit.Transport.Transport.Open(db, config);
        }
Beispiel #11
0
 /// <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);
     }
 }
Beispiel #12
0
 /// <summary>Create process for specified transport and refs updates specification.</summary>
 /// <remarks>Create process for specified transport and refs updates specification.</remarks>
 /// <param name="transport">
 /// transport between remote and local repository, used to create
 /// connection.
 /// </param>
 /// <param name="toPush">specification of refs updates (and local tracking branches).
 ///     </param>
 /// <exception cref="NGit.Errors.TransportException">NGit.Errors.TransportException</exception>
 internal PushProcess(NGit.Transport.Transport transport, ICollection <RemoteRefUpdate
                                                                       > toPush)
 {
     this.walker    = new RevWalk(transport.local);
     this.transport = transport;
     this.toPush    = new Dictionary <string, RemoteRefUpdate>();
     foreach (RemoteRefUpdate rru in toPush)
     {
         if (this.toPush.Put(rru.GetRemoteName(), rru) != null)
         {
             throw new TransportException(MessageFormat.Format(JGitText.Get().duplicateRemoteRefUpdateIsIllegal
                                                               , rru.GetRemoteName()));
         }
     }
 }
Beispiel #13
0
        public virtual void TestFindRemoteRefUpdatesTrackingRef()
        {
            remoteConfig.AddFetchRefSpec(new RefSpec("refs/heads/*:refs/remotes/test/*"));
            transport = NGit.Transport.Transport.Open(db, remoteConfig);
            ICollection <RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Sharpen.Collections
                                                                                     .NCopies(1, new RefSpec("+refs/heads/a:refs/heads/a")));

            NUnit.Framework.Assert.AreEqual(1, result.Count);
            TrackingRefUpdate tru = result.Iterator().Next().GetTrackingRefUpdate();

            NUnit.Framework.Assert.AreEqual("refs/remotes/test/a", tru.GetLocalName());
            NUnit.Framework.Assert.AreEqual("refs/heads/a", tru.GetRemoteName());
            NUnit.Framework.Assert.AreEqual(db.Resolve("refs/heads/a"), tru.GetNewObjectId());
            NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, tru.GetOldObjectId());
        }
Beispiel #14
0
        public virtual void TestFindRemoteRefUpdatesNoWildcardNoTracking()
        {
            transport = NGit.Transport.Transport.Open(db, remoteConfig);
            ICollection <RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Collections
                                                                                     .NCopies(1, new RefSpec("refs/heads/master:refs/heads/x")));

            NUnit.Framework.Assert.AreEqual(1, result.Count);
            RemoteRefUpdate rru = result.Iterator().Next();

            NUnit.Framework.Assert.IsNull(rru.GetExpectedOldObjectId());
            NUnit.Framework.Assert.IsFalse(rru.IsForceUpdate());
            NUnit.Framework.Assert.AreEqual("refs/heads/master", rru.GetSrcRef());
            NUnit.Framework.Assert.AreEqual(db.Resolve("refs/heads/master"), rru.GetNewObjectId
                                                ());
            NUnit.Framework.Assert.AreEqual("refs/heads/x", rru.GetRemoteName());
        }
Beispiel #15
0
        /// <exception cref="NGit.Errors.TransportException"></exception>
        internal BundleFetchConnection(NGit.Transport.Transport transportBundle, InputStream
                                       src)
        {
            transport = transportBundle;
            bin       = new BufferedInputStream(src);
            try
            {
                switch (ReadSignature())
                {
                case 2:
                {
                    ReadBundleV2();
                    break;
                }

                default:
                {
                    throw new TransportException(transport.uri, JGitText.Get().notABundle);
                }
                }
            }
            catch (TransportException err)
            {
                Close();
                throw;
            }
            catch (IOException err)
            {
                Close();
                throw new TransportException(transport.uri, err.Message, err);
            }
            catch (RuntimeException err)
            {
                Close();
                throw new TransportException(transport.uri, err.Message, err);
            }
        }
		/// <exception cref="NGit.Errors.TransportException"></exception>
		internal BundleFetchConnection(NGit.Transport.Transport transportBundle, InputStream
			 src)
		{
			transport = transportBundle;
			bin = new BufferedInputStream(src);
			try
			{
				switch (ReadSignature())
				{
					case 2:
					{
						ReadBundleV2();
						break;
					}

					default:
					{
						throw new TransportException(transport.uri, JGitText.Get().notABundle);
					}
				}
			}
			catch (TransportException err)
			{
				Close();
				throw;
			}
			catch (IOException err)
			{
				Close();
				throw new TransportException(transport.uri, err.Message, err);
			}
			catch (RuntimeException err)
			{
				Close();
				throw new TransportException(transport.uri, err.Message, err);
			}
		}
Beispiel #17
0
        /// <summary>Open a new transport instance to connect two repositories.</summary>
        /// <remarks>Open a new transport instance to connect two repositories.</remarks>
        /// <param name="local">existing local repository.</param>
        /// <param name="remote">
        /// location of the remote repository - may be URI or remote
        /// configuration name.
        /// </param>
        /// <param name="op">
        /// planned use of the returned Transport; the URI may differ
        /// based on the type of connection desired.
        /// </param>
        /// <returns>
        /// the new transport instance. Never null. In case of multiple URIs
        /// in remote configuration, only the first is chosen.
        /// </returns>
        /// <exception cref="Sharpen.URISyntaxException">
        /// the location is not a remote defined in the configuration
        /// file and is not a well-formed URL.
        /// </exception>
        /// <exception cref="System.NotSupportedException">the protocol specified is not supported.
        /// 	</exception>
        /// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
        /// 	</exception>
        public static NGit.Transport.Transport Open(Repository local, string remote, Transport.Operation
			 op)
        {
            RemoteConfig cfg = new RemoteConfig(local.GetConfig(), remote);
            if (DoesNotExist(cfg))
            {
                return Open(local, new URIish(remote), null);
            }
            return Open(local, cfg, op);
        }
Beispiel #18
0
        private static IList<URIish> GetURIs(RemoteConfig cfg, Transport.Operation op)
        {
            switch (op)
            {
                case Transport.Operation.FETCH:
                {
                    return cfg.URIs;
                }

                case Transport.Operation.PUSH:
                {
                    IList<URIish> uris = cfg.PushURIs;
                    if (uris.IsEmpty())
                    {
                        uris = cfg.URIs;
                    }
                    return uris;
                }

                default:
                {
                    throw new ArgumentException(op.ToString());
                }
            }
        }
Beispiel #19
0
 internal FetchProcess(NGit.Transport.Transport t, ICollection <RefSpec> f)
 {
     transport = t;
     toFetch   = f;
 }
Beispiel #20
0
        /// <summary>Open new transport instances to connect two repositories.</summary>
        /// <remarks>Open new transport instances to connect two repositories.</remarks>
        /// <param name="local">existing local repository.</param>
        /// <param name="cfg">
        /// configuration describing how to connect to the remote
        /// repository.
        /// </param>
        /// <param name="op">
        /// planned use of the returned Transport; the URI may differ
        /// based on the type of connection desired.
        /// </param>
        /// <returns>
        /// the list of new transport instances for every URI in remote
        /// configuration.
        /// </returns>
        /// <exception cref="System.NotSupportedException">the protocol specified is not supported.
        /// 	</exception>
        /// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
        /// 	</exception>
        public static IList<NGit.Transport.Transport> OpenAll(Repository local, RemoteConfig
			 cfg, Transport.Operation op)
        {
            IList<URIish> uris = GetURIs(cfg, op);
            IList<NGit.Transport.Transport> transports = new AList<NGit.Transport.Transport>(
                uris.Count);
            foreach (URIish uri in uris)
            {
                NGit.Transport.Transport tn = Open(local, uri, cfg.Name);
                tn.ApplyConfig(cfg);
                transports.AddItem(tn);
            }
            return transports;
        }
Beispiel #21
0
 public virtual void TestFindRemoteRefUpdatesTrackingRef()
 {
     remoteConfig.AddFetchRefSpec(new RefSpec("refs/heads/*:refs/remotes/test/*"));
     transport = NGit.Transport.Transport.Open(db, remoteConfig);
     ICollection<RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Sharpen.Collections
         .NCopies(1, new RefSpec("+refs/heads/a:refs/heads/a")));
     NUnit.Framework.Assert.AreEqual(1, result.Count);
     TrackingRefUpdate tru = result.Iterator().Next().GetTrackingRefUpdate();
     NUnit.Framework.Assert.AreEqual("refs/remotes/test/a", tru.GetLocalName());
     NUnit.Framework.Assert.AreEqual("refs/heads/a", tru.GetRemoteName());
     NUnit.Framework.Assert.AreEqual(db.Resolve("refs/heads/a"), tru.GetNewObjectId());
     NUnit.Framework.Assert.AreEqual(ObjectId.ZeroId, tru.GetOldObjectId());
 }
Beispiel #22
0
 public virtual void TestFindRemoteRefUpdatesNoWildcardNoTracking()
 {
     transport = NGit.Transport.Transport.Open(db, remoteConfig);
     ICollection<RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Collections
         .NCopies(1, new RefSpec("refs/heads/master:refs/heads/x")));
     NUnit.Framework.Assert.AreEqual(1, result.Count);
     RemoteRefUpdate rru = result.Iterator().Next();
     NUnit.Framework.Assert.IsNull(rru.GetExpectedOldObjectId());
     NUnit.Framework.Assert.IsFalse(rru.IsForceUpdate());
     NUnit.Framework.Assert.AreEqual("refs/heads/master", rru.GetSrcRef());
     NUnit.Framework.Assert.AreEqual(db.Resolve("refs/heads/master"), rru.GetNewObjectId
         ());
     NUnit.Framework.Assert.AreEqual("refs/heads/x", rru.GetRemoteName());
 }
		internal WalkPushConnection(WalkTransport walkTransport, WalkRemoteObjectDatabase
			 w)
		{
			transport = (NGit.Transport.Transport)walkTransport;
			local = transport.local;
			uri = transport.GetURI();
			dest = w;
		}
Beispiel #24
0
        /// <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();
                }
            }
        }
Beispiel #25
0
 internal BasePackConnection(PackTransport packTransport)
 {
     transport = (NGit.Transport.Transport)packTransport;
     local     = transport.local;
     uri       = transport.uri;
 }
Beispiel #26
0
        /// <summary>Open a new transport instance to connect two repositories.</summary>
        /// <remarks>Open a new transport instance to connect two repositories.</remarks>
        /// <param name="local">existing local repository.</param>
        /// <param name="cfg">
        /// configuration describing how to connect to the remote
        /// repository.
        /// </param>
        /// <param name="op">
        /// planned use of the returned Transport; the URI may differ
        /// based on the type of connection desired.
        /// </param>
        /// <returns>
        /// the new transport instance. Never null. In case of multiple URIs
        /// in remote configuration, only the first is chosen.
        /// </returns>
        /// <exception cref="System.NotSupportedException">the protocol specified is not supported.
        /// 	</exception>
        /// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
        /// 	</exception>
        /// <exception cref="System.ArgumentException">
        /// if provided remote configuration doesn't have any URI
        /// associated.
        /// </exception>
        public static NGit.Transport.Transport Open(Repository local, RemoteConfig cfg, Transport.Operation
			 op)
        {
            IList<URIish> uris = GetURIs(cfg, op);
            if (uris.IsEmpty())
            {
                throw new ArgumentException(MessageFormat.Format(JGitText.Get().remoteConfigHasNoURIAssociated
                    , cfg.Name));
            }
            NGit.Transport.Transport tn = Open(local, uris[0], cfg.Name);
            tn.ApplyConfig(cfg);
            return tn;
        }
Beispiel #27
0
 public virtual void TestFindRemoteRefUpdatesTwoRefSpecs()
 {
     transport = NGit.Transport.Transport.Open(db, remoteConfig);
     RefSpec specA = new RefSpec("+refs/heads/a:refs/heads/b");
     RefSpec specC = new RefSpec("+refs/heads/c:refs/heads/d");
     ICollection<RefSpec> specs = Arrays.AsList(specA, specC);
     ICollection<RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(specs);
     NUnit.Framework.Assert.AreEqual(2, result.Count);
     bool foundA = false;
     bool foundC = false;
     foreach (RemoteRefUpdate rru in result)
     {
         if ("refs/heads/a".Equals(rru.GetSrcRef()) && "refs/heads/b".Equals(rru.GetRemoteName
             ()))
         {
             foundA = true;
         }
         if ("refs/heads/c".Equals(rru.GetSrcRef()) && "refs/heads/d".Equals(rru.GetRemoteName
             ()))
         {
             foundC = true;
         }
     }
     NUnit.Framework.Assert.IsTrue(foundA);
     NUnit.Framework.Assert.IsTrue(foundC);
 }
Beispiel #28
0
        /// <summary>Open new transport instances to connect two repositories.</summary>
        /// <remarks>Open new transport instances to connect two repositories.</remarks>
        /// <param name="local">existing local repository.</param>
        /// <param name="remote">
        /// location of the remote repository - may be URI or remote
        /// configuration name.
        /// </param>
        /// <param name="op">
        /// planned use of the returned Transport; the URI may differ
        /// based on the type of connection desired.
        /// </param>
        /// <returns>
        /// the list of new transport instances for every URI in remote
        /// configuration.
        /// </returns>
        /// <exception cref="Sharpen.URISyntaxException">
        /// the location is not a remote defined in the configuration
        /// file and is not a well-formed URL.
        /// </exception>
        /// <exception cref="System.NotSupportedException">the protocol specified is not supported.
        /// 	</exception>
        /// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
        /// 	</exception>
        public static IList<NGit.Transport.Transport> OpenAll(Repository local, string remote
			, Transport.Operation op)
        {
            RemoteConfig cfg = new RemoteConfig(local.GetConfig(), remote);
            if (DoesNotExist(cfg))
            {
                AList<NGit.Transport.Transport> transports = new AList<NGit.Transport.Transport>(
                    1);
                transports.AddItem(Open(local, new URIish(remote), null));
                return transports;
            }
            return OpenAll(local, cfg, op);
        }
Beispiel #29
0
 public virtual void TestFindRemoteRefUpdatesWildcardNoTracking()
 {
     transport = NGit.Transport.Transport.Open(db, remoteConfig);
     ICollection<RemoteRefUpdate> result = transport.FindRemoteRefUpdatesFor(Sharpen.Collections
         .NCopies(1, new RefSpec("+refs/heads/*:refs/heads/test/*")));
     NUnit.Framework.Assert.AreEqual(12, result.Count);
     bool foundA = false;
     bool foundB = false;
     foreach (RemoteRefUpdate rru in result)
     {
         if ("refs/heads/a".Equals(rru.GetSrcRef()) && "refs/heads/test/a".Equals(rru.GetRemoteName
             ()))
         {
             foundA = true;
         }
         if ("refs/heads/b".Equals(rru.GetSrcRef()) && "refs/heads/test/b".Equals(rru.GetRemoteName
             ()))
         {
             foundB = true;
         }
     }
     NUnit.Framework.Assert.IsTrue(foundA);
     NUnit.Framework.Assert.IsTrue(foundB);
 }
Beispiel #30
0
		/// <summary>Create process for specified transport and refs updates specification.</summary>
		/// <remarks>Create process for specified transport and refs updates specification.</remarks>
		/// <param name="transport">
		/// transport between remote and local repository, used to create
		/// connection.
		/// </param>
		/// <param name="toPush">specification of refs updates (and local tracking branches).
		/// 	</param>
		/// <exception cref="NGit.Errors.TransportException">NGit.Errors.TransportException</exception>
		internal PushProcess(NGit.Transport.Transport transport, ICollection<RemoteRefUpdate
			> toPush)
		{
			this.walker = new RevWalk(transport.local);
			this.transport = transport;
			this.toPush = new Dictionary<string, RemoteRefUpdate>();
			foreach (RemoteRefUpdate rru in toPush)
			{
				if (this.toPush.Put(rru.GetRemoteName(), rru) != null)
				{
					throw new TransportException(MessageFormat.Format(JGitText.Get().duplicateRemoteRefUpdateIsIllegal
						, rru.GetRemoteName()));
				}
			}
		}
Beispiel #31
0
 internal FetchProcess(NGit.Transport.Transport t, ICollection<RefSpec> f)
 {
     transport = t;
     toFetch = f;
 }
		internal BasePackConnection(PackTransport packTransport)
		{
			transport = (NGit.Transport.Transport)packTransport;
			local = transport.local;
			uri = transport.uri;
		}
Beispiel #33
0
		public virtual void TestLocalTransportWithRelativePath()
		{
			FileRepository other = CreateWorkRepository();
			string otherDir = other.WorkTree.GetName();
			RemoteConfig config = new RemoteConfig(((FileBasedConfig)db.GetConfig()), "other"
				);
			config.AddURI(new URIish("../" + otherDir));
			// Should not throw NoRemoteRepositoryException
			transport = NGit.Transport.Transport.Open(db, config);
		}