Update() public method

public Update ( Config rc ) : void
rc Config
return void
Ejemplo n.º 1
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");
        }
Ejemplo n.º 2
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");
 }
Ejemplo n.º 3
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");
        }
Ejemplo n.º 4
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();
 }
Ejemplo n.º 5
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");
        }
Ejemplo n.º 6
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");
        }
		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));
		}