我在我的公司维护构建系统,该系统当前使用 CVS。该构建系统可跨多个项目和多个 CVS 存储库使用。
每当我们有一个发布里程碑时,我们都会创建一个标签。在 CVS 中,这很简单:
$ cvs tag TAG_NAME
只要在 CVS 工作目录中执行该命令,无论 CVS 模块或存储库如何,该命令都可以工作。
为了在 subversion 中做同样的事情,看起来我首先必须解析 svn info 的输出来获取存储库根。然后我可以使用以下命令创建标签:
svn cp . $REPO_ROOT/tags/TAG_NAME -m"Created tag TAG_NAME"
这当然假设 svn 存储库具有推荐的“主干、标签、分支”目录结构。因此,为了安全起见,我可能需要首先验证这一点。
仅仅将修订号映射到符号名称似乎需要大量工作。有更好的办法吗?
最佳答案
我几乎只在命令行中使用 svn,而且我很快就厌倦了输入怪物 URL。我最终编写了一个脚本 svnurl
,我从 shell 中使用它。它的运作假设“项目”具有以下形式:
.../PROJECTNAME/trunk
tags
branches
假设您位于 PROJECTNAME/branches/foo 的工作副本中的某个位置:
svnurl -tl # gives a list of tags for the current project
svnurl -tlu # the same as full urls
svnurl -t 1.1 # the url for the tag 1.1 of the current project
# analagous functions for branches
svnurl -ru # the url of the "root" of the current working copy
# eg svn://.../PROJECTNAME/branches/foo
svnurl -T # the url of the trunk of the current project
svnurl -pn # the name of the current project, `PROJECTNAME`
# ...
用法看起来像这样:
$ svn cp $(svnurl -T) $(svnurl -t 1.1.1) # tag trunk as 1.1.1
代码并不漂亮,但它为我节省了很多击键次数,并且以我意想不到的方式发挥了作用。如果您有兴趣,我愿意分享。
关于svn - 在 subversion 中自动创建标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/285251/