如何使用 SharpSVN 以编程方式“添加到忽略列表”对于文件夹
如何使用 SharpSVN 以编程方式将文件夹添加到忽略列表?
编辑:尝试:
这是我尝试过的
svnClient.GetProperty(new SvnUriTarget("svn://svn.foo.com/" + DatabaseName + "/"), SvnPropertyNames.SvnIgnore, out ignores);
ignores += " Artifacts";
var args = new SvnSetPropertyArgs() { BaseRevision = ???, LogMessage = "update ignore list" };
svnClient.SetProperty(new Uri("svn://svn.foo.com/" + DatabaseName + "/"), SvnPropertyNames.SvnIgnore, ignores, args);
但我不知道如何获取 BaseRevision (我可以手动获取它,并且可行,但我尝试过的所有 GetProperty 组合似乎都没有给我它。)
解决方案:基于伯特的回答
SvnGetPropertyArgs getArgs = new SvnGetPropertyArgs(){};
string ignores = "Artifacts";
string result;
if(svnClient.GetProperty(new SvnUriTarget("svn://svn.foo.com/" + ProjectName + "/trunk/"), SvnPropertyNames.SvnIgnore,out result))
{
ignores = result + " Artifacts"; //TODO: check for existing & tidy formatting.
}
svnClient.SetProperty(UncPath.TrimEnd('\\'), SvnPropertyNames.SvnIgnore, ignores);
SvnCommit(svnClient);
How do I use SharpSVN to programatically to add a folder to the ignore list?
EDIT: Attempted:
Here's what I've tried
svnClient.GetProperty(new SvnUriTarget("svn://svn.foo.com/" + DatabaseName + "/"), SvnPropertyNames.SvnIgnore, out ignores);
ignores += " Artifacts";
var args = new SvnSetPropertyArgs() { BaseRevision = ???, LogMessage = "update ignore list" };
svnClient.SetProperty(new Uri("svn://svn.foo.com/" + DatabaseName + "/"), SvnPropertyNames.SvnIgnore, ignores, args);
But I don't know how to get the BaseRevision (I can get it manually, and that works, but all the combinations of GetProperty I tried don't seem to give it to me.)
SOLUTION: Based on Bert's Answer
SvnGetPropertyArgs getArgs = new SvnGetPropertyArgs(){};
string ignores = "Artifacts";
string result;
if(svnClient.GetProperty(new SvnUriTarget("svn://svn.foo.com/" + ProjectName + "/trunk/"), SvnPropertyNames.SvnIgnore,out result))
{
ignores = result + " Artifacts"; //TODO: check for existing & tidy formatting.
}
svnClient.SetProperty(UncPath.TrimEnd('\\'), SvnPropertyNames.SvnIgnore, ignores);
SvnCommit(svnClient);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
忽略列表存储在包含要忽略的文件/目录的父目录的“svn:ignores”属性中。 (请参阅 Subversion 书籍 或
svn help propset
)因此要添加一个项目,您有获取原始属性值(如果存在),然后添加以空格分隔的额外项目。 SvnClient 上用于此目的的函数是 GetProperty 和 SetProperty()。
The ignore list is stored in the 'svn:ignores' property on the parent directory that contains the to be ignored file/directory. (See the Subversion book or
svn help propset
)So to add an item you have to get the original property value (if one exists) and then add the extra item separated with whitespace. The functions on SvnClient for this are GetProperty and SetProperty().