简体   繁体   English

如何在R包开发中使用git?

[英]How to use git in R package development?

I'm new to R and have started writing a medium-size project. 我是R的新手,已经开始编写一个中等规模的项目。 Even though it will be distributed as part of an application, I've decided to make a package out of it to make the organisation neater. 尽管它将作为应用程序的一部分进行分发,但我决定使用它来创建一个包以使组织更整洁。

How do I handle the fact that the DESCRIPTION file needs Version and Date fields, when I'm using version control? 当我使用版本控制时,如何处理DESCRIPTION文件需要Version和Date字段的事实? I wouldn't want to change that file with every git commit. 我不想在每次git提交时更改该文件。

Is there a standard Makefile somewhere for this? 在这个地方有一个标准的Makefile吗?

Further, I'm not completely clear on how I'd do this and still be able to use the package while developing. 此外,我不清楚我是如何做到这一点的,并且仍然可以在开发时使用该包。

If you use the devtools package you don't have to build and install your package after each edit - just use load_all() and the job is done in your working session, so you can test your changes (ideally with the testthat package). 如果您使用devtools包,则不必在每次编辑后构建和安装包 - 只需使用load_all()并在作业会话中完成作业,这样您就可以测试您的更改(理想情况下使用testthat包)。

I wrote an RPub about it: http://www.rpubs.com/geospacedman/lazydevtools 我写了一篇关于它的RPub: http ://www.rpubs.com/geospacedman/lazydevtools

You still get the option to build a package source tarball for distribution. 您仍然可以选择构建包源tarball以进行分发。

Note that git doesn't promote a mechanism for automatically updating bits of files with every commit, like the $id$ thing in SVN. 请注意,git不会提升每次提交时自动更新文件位的机制,比如SVN中的$ id $。 Linus himself said it was 'idiotic' and 'stupid': 莱纳斯自己说这是'愚蠢'和'愚蠢':

http://www.gelato.unsw.edu.au/archives/git/0610/28891.html http://www.gelato.unsw.edu.au/archives/git/0610/28891.html

If you are new to R I'd recommend using RStudio which is in my opinion the most advanced R-IDE. 如果您是R的新手,我建议使用RStudio ,这是我认为最先进的R-IDE。 It provides both: package building as well as version control . 它提供了: 包构建版本控制

I wouldn't want to change that file with every git commit. 我不想在每次git提交时更改该文件。 ... Further, I'm not completely clear on how I'd do this and still be able to use the package while developing. ...此外,我并不完全清楚我是如何做到这一点的,并且仍然可以在开发时使用该软件包。

Well typically you would have one package installed for working with and your local Git repository for developing. 通常情况下,您将安装一个用于处理的软件包以及用于开发的本地Git存储库。 When ever the development reaches the state for the next package release you would change the date and version in the DESCRIPTION file. 当开发达到下一个软件包发布的状态时,您将更改DESCRIPTION文件中的日期和版本。 Between two releases you can make as many stages, commits and pushes to your GIT as you want. 在两个版本之间,您可以根据需要制作多个阶段,提交和推送到您的GIT。

I don't change the DESCRIPTION for every commit, but I update Date and I put the current YYYYMMDD date in the version after the dash every time I actually build the package. 我没有为每次提交更改DESCRIPTION ,但是我更新了Date,并且每次实际构建包时,我都会将当前YYYYMMDD日期放在dash之后的版本中。 It's kind of the nightly build keeping track of which night it was. 这是一种夜间建筑,记录它是哪个夜晚。

At the moment I have one package in a rather active development phase that is driven by the needs of several different coworkers. 目前,我有一个包在一个相当活跃的开发阶段,由几个不同的同事的需求驱动。 The date in minor version is convenient because I can easily ask coworkers "What date is the version you use? The sessionInfo () shows it." 次要版本的日期很方便,因为我可以轻松地询问同事“您使用的版本是什么日期? sessionInfo ()显示它。”

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

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