版本 Rails 应用程序的最佳方式? [英] Best way to version a rails app?

查看:52
本文介绍了版本 Rails 应用程序的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对 rails 应用程序进行版本控制的最佳方法是什么?我们希望开始进入更结构化的测试周期,并且每个构建都有一个固定版本是其中的一部分.我们使用 subversion,但我想避免使用版本的修订号.有没有一种简单的方法可以自动执行此操作?或者我应该在应用程序助手中定义一个 app_version 方法?

What would be the best way to version a rails application? We want to start to get into more structured testing cycles and having a set version per build is a part of that. We use subversion but I would like to avoid using revision numbers for versions. Is there an easy way to do this automatically? Or should I just define a app_version method in the application helper?

(我们使用 subversion 进行源代码控制)

(We are using subversion for source control)

推荐答案

您可以使用 颠覆关键字:

本质上,你可以有一个辅助方法......

Essentially, you could have a helper method...

def app_version
    "$Id$"
end

$Id$ 是一个 svn 会扩展的关键字(上面的链接有其他你可以使用的).现在,我们在该文件上设置关键字属性,让 svn 知道它应该替换关键字(假设 application_helper.rb):

$Id$ is a keyword which svn will expand (the link above has others you could use). Now, we set the keywords property on that file to let svn know that it should be replacing keywords (let's assume application_helper.rb):

svn propset svn:keywords "Id" application_helper.rb
svn ci application_helper.rb

现在,如果您查看 application_helper.rb,它会显示(类似这样,版本、日期、用户名已更改)

Now if you look at application_helper.rb it'll read (something like this, with the version, date, user name changed)

def app_version
    "$Id: application_helper.rb 282 2009-06-26 10:34:17Z root $"
end

显然,您可以将其分配给一个变量并将其解析为所需的格式,将其包含在您的视图模板等中.或者执行相同的操作,但不使用 application_helper.rb,只需使用名为 VERSION 在您的根目录中.

Obviously, you could assign this to a variable and parse it to the required format, included it in your view templates etc. Or do the same thing but instead of application_helper.rb, just use a file called VERSION in your root dir.

这篇关于版本 Rails 应用程序的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆