当前位置: 首页>>代码示例>>C#>>正文


C# Git.Fetch方法代码示例

本文整理汇总了C#中NGit.Api.Git.Fetch方法的典型用法代码示例。如果您正苦于以下问题:C# Git.Fetch方法的具体用法?C# Git.Fetch怎么用?C# Git.Fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NGit.Api.Git的用法示例。


在下文中一共展示了Git.Fetch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestFetch

		public virtual void TestFetch()
		{
			// create other repository
			Repository db2 = CreateWorkRepository();
			Git git2 = new Git(db2);
			// setup the first repository to fetch from the second repository
			StoredConfig config = ((FileBasedConfig)db.GetConfig());
			RemoteConfig remoteConfig = new RemoteConfig(config, "test");
			URIish uri = new URIish(db2.Directory.ToURI().ToURL());
			remoteConfig.AddURI(uri);
			remoteConfig.Update(config);
			config.Save();
			// create some refs via commits and tag
			RevCommit commit = git2.Commit().SetMessage("initial commit").Call();
			RevTag tag = git2.Tag().SetName("tag").Call();
			Git git1 = new Git(db);
			RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
			git1.Fetch().SetRemote("test").SetRefSpecs(spec).Call();
			NUnit.Framework.Assert.AreEqual(commit.Id, db.Resolve(commit.Id.GetName() + "^{commit}"
				));
			NUnit.Framework.Assert.AreEqual(tag.Id, db.Resolve(tag.Id.GetName()));
		}
开发者ID:shoff,项目名称:ngit,代码行数:22,代码来源:FetchCommandTest.cs

示例2: Publish

		public override Repository Publish (string serverPath, FilePath localPath, FilePath[] files, string message, IProgressMonitor monitor)
		{
			// Initialize the repository
			RootRepository = GitUtil.Init (localPath, Url, monitor);
			NGit.Api.Git git = new NGit.Api.Git (RootRepository);
			try {
				var refs = git.Fetch ().Call ().GetAdvertisedRefs ();
				if (refs.Count > 0) {
					throw new UserException ("The remote repository already contains branches. MonoDevelop can only publish to an empty repository");
				}
			} catch {
				try {
					RootRepository.Close ();
				} catch {
				
				}
				if (Directory.Exists (RootRepository.Directory))
					Directory.Delete (RootRepository.Directory, true);
				RootRepository = null;
				throw;
			}

			RootPath = localPath;
			// Add the project files
			ChangeSet cs = CreateChangeSet (localPath);
			var cmd = git.Add ();
			foreach (FilePath fp in files) {
				cmd.AddFilepattern (RootRepository.ToGitPath (fp));
				cs.AddFile (fp);
			}
			cmd.Call ();
			
			// Create the initial commit
			cs.GlobalComment = message;
			Commit (cs, monitor);

			// Push to remote repo
			Push (monitor, "origin", "master");

			return this;
		}
开发者ID:kthguru,项目名称:monodevelop,代码行数:41,代码来源:GitRepository.cs

示例3: Fetch

        public void Fetch(Git git, BusyIndicatorProgressMonitor monitor)
        {
            FetchCommand command = git.Fetch();

            RefSpec spec = new RefSpec("refs/heads/master:refs/heads/FETCH_HEAD");

            command.SetRefSpecs(spec);
            command.SetProgressMonitor(monitor);

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, evt) =>
            {
                monitor.StartAction();

                try
                {
                    command.Call();
                }
                catch (JGitInternalException)
                {
                    // TODO:
                }
            };
            bw.RunWorkerCompleted += (s, evt) =>
            {
                monitor.CompleteAction();
            };
            bw.RunWorkerAsync();
        }
开发者ID:SatoKazuto,项目名称:BluePlumGit,代码行数:30,代码来源:MainWindowModel.cs

示例4: Fetch

        /// <summary>
        /// フェッチ
        /// </summary>
        /// <param name="git"></param>
        /// <param name="privateKeyData"></param>
        /// <param name="publicKeyData"></param>
        /// <param name="monitor"></param>
        public void Fetch(Git git, CloneEntity entity, string privateKeyData, string publicKeyData, BusyIndicatorProgressMonitor monitor)
        {
            var customConfigSessionFactory = new CustomConfigSessionFactory();

            customConfigSessionFactory.PrivateKey = privateKeyData;
            customConfigSessionFactory.PublicKey = publicKeyData;

            NGit.Transport.JschConfigSessionFactory.SetInstance(customConfigSessionFactory);

            UsernamePasswordCredentialsProvider creds = new UsernamePasswordCredentialsProvider(entity.UserName, entity.PassWord);

            FetchCommand command = git.Fetch();

            RefSpec spec = new RefSpec("refs/heads/master:refs/heads/FETCH_HEAD");

            command.SetRemoveDeletedRefs(true);
            command.SetRefSpecs(spec);
            command.SetProgressMonitor(monitor);
            command.SetCredentialsProvider(creds);

            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, evt) =>
            {
                monitor.StartAction();

                try
                {
                    command.Call();
                }
                catch (JGitInternalException)
                {
                    // TODO:
                }
            };
            bw.RunWorkerCompleted += (s, evt) =>
            {
                monitor.CompleteAction();
            };
            bw.RunWorkerAsync();
        }
开发者ID:takanemu,项目名称:BluePlumGit,代码行数:48,代码来源:MainWindowModel.cs

示例5: TestCheckoutRemoteTrackingWithoutLocalBranch

		public virtual void TestCheckoutRemoteTrackingWithoutLocalBranch()
		{
			// create second repository
			Repository db2 = CreateWorkRepository();
			Git git2 = new Git(db2);
			// setup the second repository to fetch from the first repository
			StoredConfig config = db2.GetConfig();
			RemoteConfig remoteConfig = new RemoteConfig(config, "origin");
			URIish uri = new URIish(db.Directory.ToURI().ToURL());
			remoteConfig.AddURI(uri);
			remoteConfig.Update(config);
			config.Save();
			// fetch from first repository
			RefSpec spec = new RefSpec("+refs/heads/*:refs/remotes/origin/*");
			git2.Fetch().SetRemote("origin").SetRefSpecs(spec).Call();
			// checkout remote tracking branch in second repository
			// (no local branches exist yet in second repository)
			git2.Checkout().SetName("remotes/origin/test").Call();
			NUnit.Framework.Assert.AreEqual("[Test.txt, mode:100644, content:Some change]", IndexState
				(db2, CONTENT));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:21,代码来源:CheckoutCommandTest.cs

示例6: SetUpRepoWithRemote

 /// <exception cref="System.Exception"></exception>
 private Git SetUpRepoWithRemote()
 {
     Repository remoteRepository = CreateWorkRepository();
     Git remoteGit = new Git(remoteRepository);
     // commit something
     WriteTrashFile("Test.txt", "Hello world");
     remoteGit.Add().AddFilepattern("Test.txt").Call();
     initialCommit = remoteGit.Commit().SetMessage("Initial commit").Call();
     WriteTrashFile("Test.txt", "Some change");
     remoteGit.Add().AddFilepattern("Test.txt").Call();
     secondCommit = remoteGit.Commit().SetMessage("Second commit").Call();
     // create a master branch
     RefUpdate rup = remoteRepository.UpdateRef("refs/heads/master");
     rup.SetNewObjectId(initialCommit.Id);
     rup.ForceUpdate();
     Repository localRepository = CreateWorkRepository();
     Git localGit = new Git(localRepository);
     StoredConfig config = localRepository.GetConfig();
     RemoteConfig rc = new RemoteConfig(config, "origin");
     rc.AddURI(new URIish(remoteRepository.Directory.GetPath()));
     rc.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
     rc.Update(config);
     config.Save();
     FetchResult res = localGit.Fetch().SetRemote("origin").Call();
     NUnit.Framework.Assert.IsFalse(res.GetTrackingRefUpdates().IsEmpty());
     rup = localRepository.UpdateRef("refs/heads/master");
     rup.SetNewObjectId(initialCommit.Id);
     rup.ForceUpdate();
     rup = localRepository.UpdateRef(Constants.HEAD);
     rup.Link("refs/heads/master");
     rup.SetNewObjectId(initialCommit.Id);
     rup.Update();
     return localGit;
 }
开发者ID:kenji-tan,项目名称:ngit,代码行数:35,代码来源:BranchCommandTest.cs


注:本文中的NGit.Api.Git.Fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。