2016-06-09 42 views
1

我需要使用libgit2sharp将本地存在的标签推送到远程。但我无法找到如何去做。如何使用libgit2sharp推送标签

我在libgit2sharp(问题和测试用例)的github repo中搜索了很多,但没有出现。

There are some discussions关于替代git push --tags和别人说,这个命令只是一个语法糖来git push <remote> refs/tags/*:refs/tags/*,它正是你所需要libgit2sharp做才能让你的标签是什么推动。

但我怎么能翻译这个命令

git push <remote> refs/tags/*:refs/tags/* 

进入libgit2sharp代码?

谢谢大家。

回答

3

嗯,我在我的方法中发现了问题。我正在做这样的事情:

repo.Network.Push(repo.Network.Remotes["origin"], @"refs/tags/*", options); 

但是libgit2sharp不允许使用通配符(*)。然后我做了一个测试,删除通配符,并用我的标签之一的名称进行更改,它工作。

但我仍然需要发送多个标签远程,我做了一个变通方法,通过使用foreach循环,就像这样:

foreach (var tag in repositorio.Tags) 
{ 
    repo.Network.Push(repo.Network.Remotes["origin"], tag.CanonicalName, options); 
} 

难道还有其他(更好或右)的方式来做到这一点?