简体   繁体   English

使用git / github对R包进行版本控制?

[英]Versioning an R package with git/github?

I'm having trouble determining a workflow for updating the version number of my R packages on github to avoid incorrectly named "in-between" versions. 我无法确定在github上更新我的R软件包版本号的工作流程,以避免错误地命名为“中间”版本。 Here's what I do now. 这就是我现在所做的。

  • commit and push, say, version 1.0.0, and set the release to be 1.0.0 例如,提交并推送版本1.0.0,并将版本设置为1.0.0
  • commit and push some bug fixes, etc, without changing the DESCRIPTION file 提交并推送一些错误修复等,而无需更改DESCRIPTION文件
  • eventually decide I should bump the version to, say, 1.0.1, and so commit and push an updated DESCRIPTION, then set a new release. 最终决定我应该将版本提升到1.0.1,然后提交并推送更新的描述,然后设置新版本。

The problem with this is that if someone (say, me) downloads from github after I've made some fixes but before I've bumped the version, the version they think they have is 1.0.0 (because that's what's still in the DESCRIPTION) but it's really got something in between 1.0.0 and 1.0.1. 这个问题是,如果有人(比方说我)在我做了一些修复之后从github下载但是在我碰到版本之前,他们认为他们拥有的版本是1.0.0(因为这仍然是描述中的内容) )但它真的有1.0.0和1.0.1之间的东西。

Something like this seems to be discussed at the question " Is it possible to add a version number using git / github ", where but is not specific to R and so I can't tell if it's talking about the same thing or not or how that would be implemented for R, anyway. 这样的事情似乎在“ 是否有可能使用git / github添加版本号 ”的问题中进行讨论,其中R不是特定的,所以我不知道它是否在谈论同样的事情或者如何无论如何,这将为R实施。

There's also the question " Automating version increase of R packages " which has an answer which automatically updates it, though in the comments, we see that Hadley is "basically not sold on the benefits of incrementing version automatically" ( https://github.com/hadley/devtools/issues/501 ). 还有一个问题是“ 自动增加R软件包的版本 ”,它有一个自动更新它的答案,虽然在评论中,我们看到Hadley“基本上不会出售自动增加版本的好处”( https:// github。 com / hadley / devtools / issues / 501 )。 The code there also depends on Make so isn't cross-platform. 那里的代码也取决于Make所以不是跨平台的。

I highly recommend to follow the Git Flow branching model, where: 我强烈建议遵循Git Flow分支模型,其中:

  • the master branch contains code of the latest stable release. master分支包含最新稳定版本的代码。 Use version format xyz 使用版本格式xyz
  • the develop branch contains code under development. develop分支包含正在开发的代码。 Use version format xyz-9000 使用版本格式xyz-9000

Let master be the default checkout branch on GitHub. master成为GitHub上的默认checkout分支。 That way users will always get the latest release, when they install R packages using: 这样,当用户使用以下命令安装R软件包时,用户将始终获得最新版本:

install_github("owner/repos")

Users who wish to install the developers version, can use: 希望安装开发人员版本的用户可以使用:

install_github("owner/repos@develop")

Next, if your package is also on CRAN, be strict and have master reflect exactly what is on CRAN. 接下来,如果您的软件包也在CRAN上,请严格并且master了CRAN上的确切内容。 That way the user install the same identical package version regardless whether they use: 这样,无论用户是否使用,用户都会安装相同的相同包版本:

install.packages("repos")

or 要么

install_github("owner/repos")

This way people also see the same info regardless of they visit your CRAN page or your GitHub page. 这样人们也可以看到相同的信息,无论他们访问您的CRAN页面还是您的GitHub页面。 Moreover, you can rest assured that all users will see the same stable information / version, even if you tag along updating the develop (only savvy users will be aware of this branch). 此外,您可以放心,所有用户都会看到相同的稳定信息/版本,即使您标记更新develop (只有精明的用户才会知道此分支)。

Next, when you release new versions, you can git tag them with their version number, eg 接下来,当您发布新版本时,您可以使用其版本号git tag它们,例如

git checkout master
git tag 1.2.3
git push --tags

That way users can install whatever version they'd like, eg 这样,用户可以安装他们喜欢的任何版本,例如

install_github("owner/repos@1.2.3")

Tools for this? 这个工具? The git flow extension is an awesome tool to orchestrate the above, eg git flow扩展是一个很棒的工具来协调上面的工作,例如

git checkout develop
git flow release start 1.2.4
emacs DESCRIPTION ## Update version x.y.z-9000 -> x.y.z+1
R CMD build ...
R CMD check ...
git flow release finish 1.2.4
git checkout master
git push
git push --tags
git checkout develop
emacs DESCRIPTION ## Bump version to x.y.(z+1)-9000
git commit -am "Bump develop version [ci skip]"
git push

I've used the above on a daily basis for a good two years - I cannot imagine not using it. 我已经每天使用上面的两年了 - 我无法想象不使用它。

One suggestion that I think closely follows your current workflow: 我认为一个建议密切关注您当前的工作流程:

  • After you commit and push version 1.0.0 and set the "github release" to 1.0.0, create a dev version and change the DESCRIPTION file version to 1.0.0.9000. 提交并推送版本1.0.0并将“github release”设置为1.0.0后,创建一个开发版本并将DESCRIPTION文件版本更改为1.0.0.9000。

  • Then, when you fix bugs, etc, you should move the dev version number in 然后,当您修复错误等时,您应该移动开发版本号
    the DESCRIPTION file forward to 9001, 9002, ..., n . DESCRIPTION文件转发到9001, 9002, ..., n Don't do a "github release". 不要做“github发布”。

  • When your ready, drop the .9000 and bump the version to 1.0.1, push an updated DESCRIPTION, and set a new "github release". 准备好后,删除.9000并将版本提升到1.0.1,推送更新的描述,并设置一个新的“github版本”。

This is borrowed from Hadley's solution offered in his book on R Packages. 这是借用他在R Packages的书中提供的Hadley解决方案。

"Instead always use . to separate version numbers. A released version number consists of three numbers, ... For version number 1.9.2, 1 is the major number, 9 is the minor number, and 2 is the patch number. Never use versions like 1.0, instead always spell out the three components, 1.0.0." “而是总是使用。来分隔版本号。发布的版本号由三个数字组成,...对于版本号1.9.2,1是主要号码,9是次要号码,2是补丁号码。从不使用像1.0这样的版本,而不是总是拼出三个组件,1.0.0。“

"An in-development package has a fourth component: the development version. This should start at 9000. For example, the first version of the package should be 0.0.0.9000. There are two reasons for this recommendation: first, it makes it easy to see if a package is released or in-development, and the use of the fourth place means that you're not limited to what the next version will be. 0.0.1, 0.1.0 and 1.0.0 are all greater than 0.0.0.9000." “开发中的软件包有第四个组件:开发版本。这应该从9000开始。例如,软件包的第一个版本应该是0.0.0.9000。这个建议有两个原因:第一,它使它变得容易查看包是否已发布或正在开发中,第四位的使用意味着您不限于下一个版本的内容.0.0.1,0.1.0和1.0.0都大于0.0 .0.9000“。

"Increment the development version, eg from 9000 to 9001 if you've added an important feature that another development package needs to depend on." “如果您添加了另一个开发包需要依赖的重要功能,则增加开发版本,例如从9000增加到9001。”

http://r-pkgs.had.co.nz/description.html#version http://r-pkgs.had.co.nz/description.html#version

In another section on releasing package he says: 关于发布包裹的另一节他说:

"If you've been following the advice in versioning, the version number of your in-development package will have four components, major.minor.patch.dev, where dev is at least 9000. The number 9000 is arbitrary, but provides a strong visual signal there's something different about this version number. Released packages don't have a dev component, so now you need to drop that and pick a version number based on the changes you've made. For example, if the current version is 0.8.1.9000 will the next CRAN version be 0.8.2, 0.9.0 or 1.0.0" “如果您一直在遵循版本控制方面的建议,那么开发中软件包的版本号将包含四个组件major.minor.patch.dev,其中dev至少为9000.数字9000是任意的,但提供了强大的视觉信号这个版本号有些不同。发布的软件包没有开发组件,所以现在你需要删除它并根据你所做的更改选择一个版本号。例如,如果当前版本是0.8.1.9000将下一个CRAN版本为0.8.2,0.9.0或1.0.0“

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM