A remembered remote repository, including URLs and RefSpecs. A remote configuration remembers one or more URLs for a frequently accessed remote repository as well as zero or more fetch and push specifications describing how refs should be transferred between this repository and the remote repository.
Exemplo n.º 1
0
        public void testSimple()
        {
            readConfig("[remote \"spearce\"]\n" + "url = http://www.spearce.org/egit.git\n" +
                        "fetch = +refs/heads/*:refs/remotes/spearce/*\n");

            RemoteConfig rc = new RemoteConfig(config, "spearce");
            System.Collections.Generic.List<URIish> allURIs = rc.URIs;

            Assert.AreEqual("spearce", rc.Name);
            Assert.IsNotNull(allURIs);
            Assert.IsNotNull(rc.Fetch);
            Assert.IsNotNull(rc.Push);
            Assert.IsNotNull(rc.TagOpt);
            Assert.AreEqual(0, rc.Timeout);
            Assert.AreSame(TagOpt.AUTO_FOLLOW, rc.TagOpt);

            Assert.AreEqual(1, allURIs.Count);
            Assert.AreEqual("http://www.spearce.org/egit.git", allURIs[0].ToString());

            Assert.AreEqual(1, rc.Fetch.Count);
            RefSpec spec = rc.Fetch[0];
            Assert.IsTrue(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/heads/*", spec.Source);
            Assert.AreEqual("refs/remotes/spearce/*", spec.Destination);

            Assert.AreEqual(0, rc.Push.Count);
        }
Exemplo n.º 2
0
 public void ApplyConfig(RemoteConfig cfg)
 {
     OptionUploadPack  = cfg.UploadPack;
     _fetchSpecs       = cfg.Fetch;
     TagOpt            = cfg.TagOpt;
     OptionReceivePack = cfg.ReceivePack;
     _pushSpecs        = cfg.Push;
 }
Exemplo n.º 3
0
 public override void setUp()
 {
     base.setUp();
     RepositoryConfig config = db.Config;
     remoteConfig = new RemoteConfig(config, "test");
     remoteConfig.AddURI(new URIish("http://everyones.loves.git/u/2"));
     transport = null;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Open a new transport instance to connect two repositories.
        /// </summary>
        /// <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>
        public static Transport open(Repository local, string remote,
                                     Operation op)
        {
            var cfg = new RemoteConfig(local.Config, remote);

            if (doesNotExist(cfg))
            {
                return(open(local, new URIish(remote)));
            }
            return(open(local, cfg, op));
        }
Exemplo n.º 5
0
        public static Transport Open(Repository local, string remote)
        {
            var           cfg  = new RemoteConfig(local.Config, remote);
            List <URIish> uris = cfg.URIs;

            if (uris.Count == 0)
            {
                return(Open(local, new URIish(remote)));
            }
            return(Open(local, cfg));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Support for Transport over HTTP and Git (Anon+SSH)
        /// </summary>
        /// <param name="local"></param>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public static Transport Open(Repository local, RemoteConfig cfg)
        {
            if (cfg.URIs.Count == 0)
            {
                throw new ArgumentException("Remote config \"" + cfg.Name + "\" has no URIs associated");
            }

            Transport tn = Open(local, cfg.URIs[0]);

            tn.ApplyConfig(cfg);
            return(tn);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Apply provided remote configuration on this transport.
 /// </summary>
 /// <param name="cfg">configuration to apply on this transport.</param>
 public void ApplyConfig(RemoteConfig cfg)
 {
     if (cfg == null)
     {
         throw new ArgumentNullException("cfg");
     }
     OptionUploadPack  = cfg.UploadPack;
     OptionReceivePack = cfg.ReceivePack;
     TagOpt            = cfg.TagOpt;
     _fetch            = cfg.Fetch;
     _push             = cfg.Push;
     _timeout          = cfg.Timeout;
 }
Exemplo n.º 8
0
        public static List <Transport> openAll(Repository local, RemoteConfig cfg)
        {
            List <URIish> uris      = cfg.URIs;
            var           tranports = new List <Transport>(uris.Count);

            foreach (URIish uri in uris)
            {
                Transport tn = Open(local, uri);
                tn.ApplyConfig(cfg);
                tranports.Add(tn);
            }
            return(tranports);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Open new transport instances to connect two repositories.
        /// </summary>
        /// <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>
        public static List <Transport> openAll(Repository local,
                                               string remote, Operation op)
        {
            var cfg = new RemoteConfig(local.Config, remote);

            if (doesNotExist(cfg))
            {
                var transports = new List <Transport>(1);
                transports.Add(open(local, new URIish(remote)));
                return(transports);
            }
            return(openAll(local, cfg, op));
        }
Exemplo n.º 10
0
        public void testAddURI()
        {
            readConfig(string.Empty);

            URIish uri = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.AreEqual(0, rc.URIs.Count);

            Assert.IsTrue(rc.AddURI(uri));
            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(uri, rc.URIs[0]);

            Assert.IsFalse(rc.AddURI(new URIish(uri.ToString())));
            Assert.AreEqual(1, rc.URIs.Count);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Open a new transport instance to connect two repositories.
        /// </summary>
        /// <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></returns>
        public static Transport open(Repository local,
                                     RemoteConfig cfg, Operation op)
        {
            List <URIish> uris = getURIs(cfg, op);

            if (uris.isEmpty())
            {
                throw new ArgumentException(
                          "Remote config \""
                          + cfg.Name + "\" has no URIs associated");
            }
            Transport tn = open(local, uris[0]);

            tn.ApplyConfig(cfg);
            return(tn);
        }
Exemplo n.º 12
0
        public static List <Transport> openAll(Repository local, string remote)
        {
            var           cfg  = new RemoteConfig(local.Config, remote);
            List <URIish> uris = cfg.URIs;

            if (uris.isEmpty())
            {
                var transports = new List <Transport>(1)
                {
                    Open(local, new URIish(remote))
                };
                return(transports);
            }

            return(openAll(local, cfg));
        }
Exemplo n.º 13
0
        private static List <URIish> getURIs(RemoteConfig cfg, Operation op)
        {
            switch (op)
            {
            case Operation.FETCH:
                return(cfg.URIs);

            case Operation.PUSH:
                List <URIish> uris = cfg.PushURIs;
                if (uris.Count == 0)
                {
                    uris = cfg.URIs;
                }
                return(uris);

            default:
                throw new ArgumentException(op.ToString());
            }
        }
Exemplo n.º 14
0
        public void testRemoveOnlyURI()
        {
            readConfig(string.Empty);

            URIish a = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.IsTrue(rc.AddURI(a));

            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);

            Assert.IsTrue(rc.RemoveURI(a));
            Assert.AreEqual(0, rc.URIs.Count);
        }
Exemplo n.º 15
0
        public void testRemoveMiddleURI()
        {
            readConfig(string.Empty);

            URIish a = new URIish("/some/dir");
            URIish b = new URIish("/another/dir");
            URIish c = new URIish("/more/dirs");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.IsTrue(rc.AddURI(a));
            Assert.IsTrue(rc.AddURI(b));
            Assert.IsTrue(rc.AddURI(c));

            Assert.AreEqual(3, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(b, rc.URIs[1]);
            Assert.AreEqual(c, rc.URIs[2]);

            Assert.IsTrue(rc.RemoveURI(b));
            Assert.AreEqual(2, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(c, rc.URIs[1]);
        }
Exemplo n.º 16
0
 /// <summary>
 /// Open a new transport instance to connect two repositories.
 /// <para/>
 /// This method assumes <see cref="Operation.FETCH"/>.
 /// </summary>
 /// <param name="local">existing local repository.</param>
 /// <param name="cfg">
 /// configuration describing how to connect to the remote
 /// repository.
 /// </param>
 /// <returns>
 /// the new transport instance. Never null. In case of multiple URIs
 /// in remote configuration, only the first is chosen.
 /// </returns>
 public static Transport open(Repository local, RemoteConfig cfg)
 {
     return(open(local, cfg, Operation.FETCH));
 }
Exemplo n.º 17
0
 public static Transport Open(Repository local, string remote)
 {
     var cfg = new RemoteConfig(local.Config, remote);
     List<URIish> uris = cfg.URIs;
     if (uris.Count == 0)
     {
         return Open(local, new URIish(remote));
     }
     return Open(local, cfg);
 }
Exemplo n.º 18
0
        public void testUploadPack()
        {
            readConfig("[remote \"example\"]\n"
                        + "url = [email protected]:egit.git\n"
                        + "fetch = +refs/heads/*:refs/remotes/example/*\n"
                        + "uploadpack = /path/to/git/git-upload-pack\n"
                        + "receivepack = /path/to/git/git-receive-pack\n");

            RemoteConfig rc = new RemoteConfig(config, "example");
            System.Collections.Generic.List<URIish> allURIs = rc.URIs;

            Assert.AreEqual("example", rc.Name);
            Assert.IsNotNull(allURIs);
            Assert.IsNotNull(rc.Fetch);
            Assert.IsNotNull(rc.Push);

            Assert.AreEqual(1, allURIs.Count);
            Assert.AreEqual("[email protected]:egit.git", allURIs[0].ToString());

            Assert.AreEqual(1, rc.Fetch.Count);
            RefSpec spec = rc.Fetch[0];
            Assert.IsTrue(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/heads/*", spec.Source);
            Assert.AreEqual("refs/remotes/example/*", spec.Destination);

            Assert.AreEqual(0, rc.Push.Count);

            Assert.AreEqual("/path/to/git/git-upload-pack", rc.UploadPack);
            Assert.AreEqual("/path/to/git/git-receive-pack", rc.ReceivePack);
        }
Exemplo n.º 19
0
        public void testSimpleTimeout()
        {
            readConfig("[remote \"spearce\"]\n"
                    + "url = http://www.spearce.org/egit.git\n"
                    + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
                    + "timeout = 12\n");

            RemoteConfig rc = new RemoteConfig(config, "spearce");
            Assert.AreEqual(12, rc.Timeout);
        }
Exemplo n.º 20
0
 public void testSaveTimeout()
 {
     RemoteConfig rc = new RemoteConfig(config, "origin");
     rc.AddURI(new URIish("/some/dir"));
     rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
     rc.Timeout = 60;
     rc.Update(config);
     checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
             + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
             + "\ttimeout = 60\n");
 }
Exemplo n.º 21
0
 public static List<Transport> openAll(Repository local, RemoteConfig cfg)
 {
     if (cfg == null)
         throw new ArgumentNullException ("cfg");
     List<URIish> uris = cfg.URIs;
     var tranports = new List<Transport>(uris.Count);
     foreach (URIish uri in uris)
     {
         Transport tn = Open(local, uri);
         tn.ApplyConfig(cfg);
         tranports.Add(tn);
     }
     return tranports;
 }
Exemplo n.º 22
0
        /// <summary>
        /// Support for Transport over HTTP and Git (Anon+SSH)
        /// </summary>
        /// <param name="local"></param>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public static Transport Open(Repository local, RemoteConfig cfg)
        {
            if (cfg == null)
                throw new ArgumentNullException ("cfg");
            if (cfg.URIs.Count == 0)
            {
                throw new ArgumentException("Remote config \"" + cfg.Name + "\" has no URIs associated");
            }

            Transport tn = Open(local, cfg.URIs[0]);
            tn.ApplyConfig(cfg);
            return tn;
        }
Exemplo n.º 23
0
        public void testBackup()
        {
            readConfig("[remote \"backup\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "url = [email protected]:/srv/git/egit.git\n"
                        + "push = +refs/heads/*:refs/heads/*\n"
                        + "push = refs/tags/*:refs/tags/*\n");

            RemoteConfig rc = new RemoteConfig(config, "backup");
            System.Collections.Generic.List<URIish> allURIs = rc.URIs;

            Assert.AreEqual("backup", rc.Name);
            Assert.IsNotNull(allURIs);
            Assert.IsNotNull(rc.Fetch);
            Assert.IsNotNull(rc.Push);

            Assert.AreEqual(2, allURIs.Count);
            Assert.AreEqual("http://www.spearce.org/egit.git", allURIs[0].ToString());
            Assert.AreEqual("[email protected]:/srv/git/egit.git", allURIs[1].ToString());

            Assert.AreEqual(0, rc.Fetch.Count);

            Assert.AreEqual(2, rc.Push.Count);
            RefSpec spec = rc.Push[0];
            Assert.IsTrue(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/heads/*", spec.Source);
            Assert.AreEqual("refs/heads/*", spec.Destination);

            spec = rc.Push[1];
            Assert.IsFalse(spec.Force);
            Assert.IsTrue(spec.Wildcard);
            Assert.AreEqual("refs/tags/*", spec.Source);
            Assert.AreEqual("refs/tags/*", spec.Destination);
        }
Exemplo n.º 24
0
 /// <summary>
 /// Open a new transport instance to connect two repositories.
 /// <para/>
 /// This method assumes <see cref="Operation.FETCH"/>.
 /// </summary>
 /// <param name="local">existing local repository.</param>
 /// <param name="cfg">
 /// configuration describing how to connect to the remote
 /// repository.
 /// </param>
 /// <returns>
 /// the list of new transport instances for every URI in remote
 /// configuration.
 /// </returns>
 public static List <Transport> openAll(Repository local, RemoteConfig cfg)
 {
     return(openAll(local, cfg, Operation.FETCH));
 }
Exemplo n.º 25
0
 private static bool doesNotExist(RemoteConfig cfg)
 {
     return(cfg.URIs.Count == 0 && cfg.PushURIs.Count == 0);
 }
Exemplo n.º 26
0
 private static bool doesNotExist(RemoteConfig cfg)
 {
     return(cfg.URIs.isEmpty() && cfg.PushURIs.isEmpty());
 }
Exemplo n.º 27
0
        public void testSaveNoTags()
        {
            RemoteConfig rc = new RemoteConfig(config, "origin");
            rc.AddURI(new URIish("/some/dir"));
            rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
            rc.SetTagOpt(TagOpt.NO_TAGS);
            rc.Update(config);

            checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
                    + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
                    + "\ttagopt = --no-tags\n");
        }
Exemplo n.º 28
0
 private static bool doesNotExist(RemoteConfig cfg)
 {
     return cfg.URIs.Count == 0 && cfg.PushURIs.Count == 0;
 }
Exemplo n.º 29
0
        public void testSaveRemoveLastURI()
        {
            readConfig("[remote \"spearce\"]\n"
                        + "url = http://www.spearce.org/egit.git\n"
                        + "url = /some/dir\n"
                        + "fetch = +refs/heads/*:refs/remotes/spearce/*\n");

            RemoteConfig rc = new RemoteConfig(config, "spearce");
            Assert.AreEqual(2, rc.URIs.Count);
            rc.RemoveURI(new URIish("/some/dir"));
            Assert.AreEqual(1, rc.URIs.Count);
            rc.Update(config);

            checkConfig("[remote \"spearce\"]\n"
                    + "\turl = http://www.spearce.org/egit.git\n"
                    + "\tfetch = +refs/heads/*:refs/remotes/spearce/*\n");
        }
Exemplo n.º 30
0
 private static bool doesNotExist(RemoteConfig cfg)
 {
     return cfg.URIs.isEmpty() && cfg.PushURIs.isEmpty();
 }
Exemplo n.º 31
0
 public void testSimpleNoTags()
 {
     readConfig("[remote \"spearce\"]\n"
                 + "url = http://www.spearce.org/egit.git\n"
                 + "fetch = +refs/heads/*:refs/remotes/spearce/*\n"
                 + "tagopt = --no-tags\n");
     RemoteConfig rc = new RemoteConfig(config, "spearce");
     Assert.AreSame(TagOpt.NO_TAGS, rc.TagOpt);
 }
Exemplo n.º 32
0
 public static List<Transport> openAll(Repository local, RemoteConfig cfg)
 {
     List<URIish> uris = cfg.URIs;
     var tranports = new List<Transport>(uris.Count);
     foreach (URIish uri in uris)
     {
         Transport tn = Open(local, uri);
         tn.ApplyConfig(cfg);
         tranports.Add(tn);
     }
     return tranports;
 }
Exemplo n.º 33
0
        public void testUnknown()
        {
            readConfig(string.Empty);

            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.AreEqual(0, rc.URIs.Count);
            Assert.AreEqual(0, rc.Fetch.Count);
            Assert.AreEqual(0, rc.Push.Count);
            Assert.AreEqual("git-upload-pack", rc.UploadPack);
            Assert.AreEqual("git-receive-pack", rc.ReceivePack);
        }
Exemplo n.º 34
0
 private void saveRemote(URIish uri)
 {
     var repo = Repository._internal_repo;
     RemoteConfig rc = new RemoteConfig(repo.Config, OriginName);
     rc.AddURI(uri);
     rc.AddFetchRefSpec(new RefSpec().SetForce(true).SetSourceDestination(Constants.R_HEADS + "*",
         Constants.R_REMOTES + OriginName + "/*"));
     rc.Update(repo.Config);
     repo.Config.save();
 }
Exemplo n.º 35
0
        public static List<Transport> openAll(Repository local, string remote)
        {
            var cfg = new RemoteConfig(local.Config, remote);
            List<URIish> uris = cfg.URIs;
            if (uris.isEmpty())
            {
                var transports = new List<Transport>(1) { Open(local, new URIish(remote)) };
                return transports;
            }

            return openAll(local, cfg);
        }
Exemplo n.º 36
0
 public void ApplyConfig(RemoteConfig cfg)
 {
     OptionUploadPack = cfg.UploadPack;
     _fetchSpecs = cfg.Fetch;
     TagOpt = cfg.TagOpt;
     OptionReceivePack = cfg.ReceivePack;
     _pushSpecs = cfg.Push;
 }
Exemplo n.º 37
0
 public static Transport Open(Repository local, string remote)
 {
     if (local == null)
         throw new ArgumentNullException ("local");
     var cfg = new RemoteConfig(local.Config, remote);
     List<URIish> uris = cfg.URIs;
     if (uris.Count == 0)
     {
         return Open(local, new URIish(remote));
     }
     return Open(local, cfg);
 }
		protected override void Run ()
		{
			var cloneDialog = new CloneRepositoryDialog ();
			cloneDialog.Run ();
			cloneDialog.Destroy ();
			
			var repositoryPath = cloneDialog.RepositoryPath;
			URIish source = new URIish (repositoryPath);
			var originName = cloneDialog.OriginName;
			var destination = cloneDialog.WorkingDirectory;
			var workingDirectory = Path.Combine (destination, Constants.DOT_GIT);
			
			if (string.IsNullOrEmpty (originName))
				originName = Constants.DEFAULT_REMOTE_NAME;
			
			var rep = new GitSharp.Core.Repository (new DirectoryInfo (workingDirectory));
			rep.Create ();
			rep.Config.setBoolean ("core", null, "bare", false);
			rep.Config.save ();
			
			var rc = new RemoteConfig (rep.Config, originName);
			rc.AddURI (source);
			rc.AddFetchRefSpec (new RefSpec ().SetForce (true).SetSourceDestination (
					Constants.R_HEADS + "*", 
					Constants.R_REMOTES + originName + "/*"));
			rc.Update (rep.Config);
			rep.Config.save ();
			
			Transport tn = Transport.open (rep, originName);
			FetchResult fetchResult = null;
			try 
			{
				fetchResult = tn.fetch (new NullProgressMonitor (), null);
			} 
			catch 
			{
				tn.Dispose ();
			}
			
			GitSharp.Core.Ref branch = null;
			if (fetchResult != null) 
			{
				var headId = fetchResult.GetAdvertisedRef (Constants.HEAD);
				var availableRefs = new List<GitSharp.Core.Ref> ();
				
				foreach (GitSharp.Core.Ref r in fetchResult.AdvertisedRefs) 
				{
					var n = r.Name;
					if (!n.StartsWith (Constants.R_HEADS))
						continue;
					
					availableRefs.Add (r);
					if (headId == null || branch != null)
						continue;
					
					if (r.ObjectId.Equals (headId.ObjectId))
						branch = r;
				}
				
				availableRefs.Sort (RefComparator.INSTANCE);
				
				if (headId != null && branch == null)
					branch = headId;
			}
			
			if (branch != null) 
			{
				if (!Constants.HEAD.Equals (branch.Name)) 
				{
					//rep. (Constants.HEAD, branch.Name);
					GitSharp.Core.Commit commit = rep.MapCommit (branch.ObjectId);
					RefUpdate update = rep.UpdateRef (Constants.HEAD);
					update.NewObjectId = commit.CommitId;
					update.forceUpdate ();
					
					var index = new GitIndex (rep);
					var tree = commit.TreeEntry;
					WorkDirCheckout co = new WorkDirCheckout (rep, rep.WorkingDirectory, index, tree);
					co.checkout ();
					index.write ();
				}
			} 
			else 
			{
				MessageService.ShowError ("Cannot clone: no HEAD advertised by remote.");
			}
			
			MessageService.ShowMessage(string.Format("Finished cloning {0} to {1}", 
					repositoryPath, 
					destination));
		}
Exemplo n.º 39
0
        public static List<Transport> openAll(Repository local, string remote)
        {
            if (local == null)
                throw new ArgumentNullException ("local");
            var cfg = new RemoteConfig(local.Config, remote);
            List<URIish> uris = cfg.URIs;
            if (uris.isEmpty())
            {
                var transports = new List<Transport>(1) { Open(local, new URIish(remote)) };
                return transports;
            }

            return openAll(local, cfg);
        }
Exemplo n.º 40
0
        public void testCreateOrigin()
        {
            RemoteConfig rc = new RemoteConfig(config, Constants.DEFAULT_REMOTE_NAME);
            rc.AddURI(new URIish("/some/dir"));
            rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
            rc.Update(config);

            checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
                    + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n");
        }
Exemplo n.º 41
0
 public void ApplyConfig(RemoteConfig cfg)
 {
     if (cfg == null)
         throw new ArgumentNullException ("cfg");
     OptionUploadPack = cfg.UploadPack;
     _fetchSpecs = cfg.Fetch;
     TagOpt = cfg.TagOpt;
     OptionReceivePack = cfg.ReceivePack;
     _pushSpecs = cfg.Push;
 }
Exemplo n.º 42
0
        public void testSaveAllTags()
        {
            RemoteConfig rc = new RemoteConfig(config, Constants.DEFAULT_REMOTE_NAME);
            rc.AddURI(new URIish("/some/dir"));
            rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + rc.Name + "/*"));
            rc.SetTagOpt(TagOpt.FETCH_TAGS);
            rc.Update(config);

            checkConfig("[remote \"origin\"]\n" + "\turl = /some/dir\n"
                    + "\tfetch = +refs/heads/*:refs/remotes/origin/*\n"
                    + "\ttagopt = --tags\n");
        }
Exemplo n.º 43
0
        private static List<URIish> getURIs(RemoteConfig cfg, Operation op)
        {
            switch (op)
            {
                case Operation.FETCH:
                    return cfg.URIs;

                case Operation.PUSH:
                    List<URIish> uris = cfg.PushURIs;
                    if (uris.Count == 0)
                    {
                        uris = cfg.URIs;
                    }
                    return uris;

                default:
                    throw new ArgumentException(op.ToString());
            }
        }
Exemplo n.º 44
0
 /// <summary>
 /// Open a new transport instance to connect two repositories.
 /// <para/>
 /// This method assumes <see cref="Operation.FETCH"/>.
 /// </summary>
 /// <param name="local">existing local repository.</param>
 /// <param name="cfg">
 /// configuration describing how to connect to the remote
 /// repository.
 /// </param>
 /// <returns>
 /// the list of new transport instances for every URI in remote
 /// configuration.
 /// </returns>
 public static List<Transport> openAll(Repository local, RemoteConfig cfg)
 {
     return openAll(local, cfg, Operation.FETCH);
 }