本文整理汇总了C#中NGit.Transport.RemoteConfig.AddPushRefSpec方法的典型用法代码示例。如果您正苦于以下问题:C# RemoteConfig.AddPushRefSpec方法的具体用法?C# RemoteConfig.AddPushRefSpec怎么用?C# RemoteConfig.AddPushRefSpec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NGit.Transport.RemoteConfig
的用法示例。
在下文中一共展示了RemoteConfig.AddPushRefSpec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPushWithRefSpecFromConfig
public virtual void TestPushWithRefSpecFromConfig()
{
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("HEAD:refs/heads/newbranch"));
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/newbranch"
));
}
示例2: 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);
}
}