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


C# Git.Push方法代码示例

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


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

示例1: Push

		public ICommandResponse Push (string path)
		{
			Git git = new Git(new FileRepository(ToGitDirString(path)));
			Iterable<PushResult> pushResults = git.Push().Call();
			ICommandResponse result = new NGitPushResultAdapter(pushResults);
			return result;
		}
开发者ID:draptik,项目名称:RepoSync,代码行数:7,代码来源:NGitStrategy.cs

示例2: TestTrackingUpdate

		public virtual void TestTrackingUpdate()
		{
			Repository db2 = CreateBareRepository();
			string remote = "origin";
			string branch = "refs/heads/master";
			string trackingBranch = "refs/remotes/" + remote + "/master";
			Git git = new Git(db);
			RevCommit commit1 = git.Commit().SetMessage("Initial commit").Call();
			RefUpdate branchRefUpdate = db.UpdateRef(branch);
			branchRefUpdate.SetNewObjectId(commit1.Id);
			branchRefUpdate.Update();
			RefUpdate trackingBranchRefUpdate = db.UpdateRef(trackingBranch);
			trackingBranchRefUpdate.SetNewObjectId(commit1.Id);
			trackingBranchRefUpdate.Update();
			StoredConfig config = ((FileBasedConfig)db.GetConfig());
			RemoteConfig remoteConfig = new RemoteConfig(config, remote);
			URIish uri = new URIish(db2.Directory.ToURI().ToURL());
			remoteConfig.AddURI(uri);
			remoteConfig.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/" + remote +
				 "/*"));
			remoteConfig.Update(config);
			config.Save();
			RevCommit commit2 = git.Commit().SetMessage("Commit to push").Call();
			RefSpec spec = new RefSpec(branch + ":" + branch);
			Iterable<PushResult> resultIterable = git.Push().SetRemote(remote).SetRefSpecs(spec
				).Call();
			PushResult result = resultIterable.Iterator().Next();
			TrackingRefUpdate trackingRefUpdate = result.GetTrackingRefUpdate(trackingBranch);
			NUnit.Framework.Assert.IsNotNull(trackingRefUpdate);
			NUnit.Framework.Assert.AreEqual(trackingBranch, trackingRefUpdate.GetLocalName());
			NUnit.Framework.Assert.AreEqual(branch, trackingRefUpdate.GetRemoteName());
			NUnit.Framework.Assert.AreEqual(commit2.Id, trackingRefUpdate.GetNewObjectId());
			NUnit.Framework.Assert.AreEqual(commit2.Id, db.Resolve(trackingBranch));
			NUnit.Framework.Assert.AreEqual(commit2.Id, db2.Resolve(branch));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:35,代码来源:PushCommandTest.cs

示例3: TestPushWithoutPushRefSpec

		public virtual void TestPushWithoutPushRefSpec()
		{
			Git git = new Git(db);
			Git git2 = new Git(CreateBareRepository());
			StoredConfig config = git.GetRepository().GetConfig();
			RemoteConfig remoteConfig = new RemoteConfig(config, "test");
			URIish uri = new URIish(git2.GetRepository().Directory.ToURI().ToURL());
			remoteConfig.AddURI(uri);
			remoteConfig.AddFetchRefSpec(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
			remoteConfig.Update(config);
			config.Save();
			WriteTrashFile("f", "content of f");
			git.Add().AddFilepattern("f").Call();
			RevCommit commit = git.Commit().SetMessage("adding f").Call();
			git.Checkout().SetName("not-pushed").SetCreateBranch(true).Call();
			git.Checkout().SetName("branchtopush").SetCreateBranch(true).Call();
			NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/branchtopush"
				));
			NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/not-pushed"
				));
			NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/master"
				));
			git.Push().SetRemote("test").Call();
			NUnit.Framework.Assert.AreEqual(commit.Id, git2.GetRepository().Resolve("refs/heads/branchtopush"
				));
			NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/not-pushed"
				));
			NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/master"
				));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:30,代码来源:PushCommandTest.cs

示例4: TestPush

		public virtual void TestPush()
		{
			// create other repository
			Repository db2 = CreateWorkRepository();
			// setup the first 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();
			Git git1 = new Git(db);
			// create some refs via commits and tag
			RevCommit commit = git1.Commit().SetMessage("initial commit").Call();
			Ref tagRef = git1.Tag().SetName("tag").Call();
			try
			{
				db2.Resolve(commit.Id.GetName() + "^{commit}");
				NUnit.Framework.Assert.Fail("id shouldn't exist yet");
			}
			catch (MissingObjectException)
			{
			}
			// we should get here
			RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
			git1.Push().SetRemote("test").SetRefSpecs(spec).Call();
			NUnit.Framework.Assert.AreEqual(commit.Id, db2.Resolve(commit.Id.GetName() + "^{commit}"
				));
			NUnit.Framework.Assert.AreEqual(tagRef.GetObjectId(), db2.Resolve(tagRef.GetObjectId
				().GetName()));
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:31,代码来源:PushCommandTest.cs

示例5: TestPushRefUpdate

		public virtual void TestPushRefUpdate()
		{
			Git git = new Git(db);
			Git git2 = new Git(CreateBareRepository());
			StoredConfig config = git.GetRepository().GetConfig();
			RemoteConfig remoteConfig = new RemoteConfig(config, "test");
			URIish uri = new URIish(git2.GetRepository().Directory.ToURI().ToURL());
			remoteConfig.AddURI(uri);
			remoteConfig.AddPushRefSpec(new RefSpec("+refs/heads/*:refs/heads/*"));
			remoteConfig.Update(config);
			config.Save();
			WriteTrashFile("f", "content of f");
			git.Add().AddFilepattern("f").Call();
			RevCommit commit = git.Commit().SetMessage("adding f").Call();
			NUnit.Framework.Assert.AreEqual(null, git2.GetRepository().Resolve("refs/heads/master"
				));
			git.Push().SetRemote("test").Call();
			NUnit.Framework.Assert.AreEqual(commit.Id, git2.GetRepository().Resolve("refs/heads/master"
				));
			git.BranchCreate().SetName("refs/heads/test").Call();
			git.Checkout().SetName("refs/heads/test").Call();
			for (int i = 0; i < 6; i++)
			{
				WriteTrashFile("f" + i, "content of f" + i);
				git.Add().AddFilepattern("f" + i).Call();
				commit = git.Commit().SetMessage("adding f" + i).Call();
				git.Push().SetRemote("test").Call();
				git2.GetRepository().GetAllRefs();
				NUnit.Framework.Assert.AreEqual(commit.Id, git2.GetRepository().Resolve("refs/heads/test"
					), "failed to update on attempt " + i);
			}
		}
开发者ID:LunarLanding,项目名称:ngit,代码行数:32,代码来源:PushCommandTest.cs


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