如何在文件中显示最新版本?

时间:2022-08-15 13:55:11

I'm wondering how do you deal with displaying release revision number when pushing live new versions of your app?

我想知道在推送你的应用程序的实时新版本时,你如何处理显示版本号?

You can use $Rev$ in a file to get latest revision, but only after you update the file.

您可以在文件中使用$ Rev $来获取最新版本,但只能在更新文件后使用。

What if I want to update a string in one file every time I change any file in the repository/directory?

如果我想在每次更改存储库/目录中的任何文件时更新一个文件中的字符串,该怎么办?

Is there a way?

有办法吗?

6 个解决方案

#1


2  

Did you try to use hooks? They work on server-side only but may do the trick. Otherwise I would just call a script do update the revision if the keywords aren't suitable for you.

你试过用钩子吗?它们只在服务器端工作,但可能会有所作为。否则我只会调用脚本来更新修订版,如果关键字不适合你。

#2


8  

The best way to do this is have a build script for releases that will determine the revision number using svnversion or svn info and insert it into a file. It's always helpful to have a script which:

执行此操作的最佳方法是使用svnversion或svn info确定版本号的版本的构建脚本,并将其插入到文件中。拥有一个脚本总是有帮助的:

  1. checks out a clean copy of the source into an empty directory
  2. 将源的干净副本签出到空目录中

  3. uses svnversion or something similar to compute a build number
  4. 使用svnversion或类似的东西来计算内部版本号

  5. compiles source into a product
  6. 将源代码编译成产品

  7. creates an archive (zip or tarball or whatever) of the product
  8. 创建产品的存档(zip或tarball或其他)

  9. cleans up: deletes everything but the archive
  10. 清理:删除除存档之外的所有内容

Then you have a one-step process to create a release with an easily identifiable version. It also helps you avoid giving someone a build from your own working copy, which may have changes that were never checked into source control.

然后,您可以通过一个步骤创建具有易于识别版本的版本。它还可以帮助您避免从您自己的工作副本中为某人提供构建,这些副本可能具有从未在源代码管理中检查过的更改。

#3


3  

There is a simple tool in TortoiseSVN named SubWCRev.exe. It takes revision from path and create file from your own template. You can use it as prebuild command.

TortoiseSVN中有一个名为SubWCRev.exe的简单工具。它需要从路径进行修订并从您自己的模板创建文件。您可以将它用作prebuild命令。

#4


2  

Automatically update the file as part of building/deploying the release.

在构建/部署版本时自动更新文件。

#5


1  

On the one project where I had a reason do this, I cheated: it calls svnversion on itself when it starts up.

在我有理由这样做的一个项目中,我作弊:它在启动时调用自身的svnversion。

#6


1  

As alexander said, one way is to update the revision as part of the build process.

正如亚历山大所说,一种方法是将修订更新为构建过程的一部分。

One method of doing this is to take your release builds from an automated build process triggered from your version control checkin, by using a tool such as buildbot.

这样做的一种方法是使用诸如buildbot之类的工具从版本控制签入触发的自动构建过程中获取发布版本。

A scenario might be to trigger the automated build using the post-hook script on your subversion repository. This causes your buildbot to update to the most recently checked in revision. Your build script (eg. Makefile) would use 'svnversion' (or 'svn info' and grep) to read the repository revision and write it into a header file before the build takes place.

方案可能是使用subversion存储库上的post-hook脚本触发自动构建。这会导致您的buildbot更新到最近签入的修订版本。您的构建脚本(例如Makefile)将使用'svnversion'(或'svn info'和grep)来读取存储库修订版,并在构建之前将其写入头文件。

After the successful build, automatically check this file back into the repository with a suitable comment about the release version.

成功构建之后,自动将此文件重新检入存储库,并提供有关发布版本的适当注释。

#1


2  

Did you try to use hooks? They work on server-side only but may do the trick. Otherwise I would just call a script do update the revision if the keywords aren't suitable for you.

你试过用钩子吗?它们只在服务器端工作,但可能会有所作为。否则我只会调用脚本来更新修订版,如果关键字不适合你。

#2


8  

The best way to do this is have a build script for releases that will determine the revision number using svnversion or svn info and insert it into a file. It's always helpful to have a script which:

执行此操作的最佳方法是使用svnversion或svn info确定版本号的版本的构建脚本,并将其插入到文件中。拥有一个脚本总是有帮助的:

  1. checks out a clean copy of the source into an empty directory
  2. 将源的干净副本签出到空目录中

  3. uses svnversion or something similar to compute a build number
  4. 使用svnversion或类似的东西来计算内部版本号

  5. compiles source into a product
  6. 将源代码编译成产品

  7. creates an archive (zip or tarball or whatever) of the product
  8. 创建产品的存档(zip或tarball或其他)

  9. cleans up: deletes everything but the archive
  10. 清理:删除除存档之外的所有内容

Then you have a one-step process to create a release with an easily identifiable version. It also helps you avoid giving someone a build from your own working copy, which may have changes that were never checked into source control.

然后,您可以通过一个步骤创建具有易于识别版本的版本。它还可以帮助您避免从您自己的工作副本中为某人提供构建,这些副本可能具有从未在源代码管理中检查过的更改。

#3


3  

There is a simple tool in TortoiseSVN named SubWCRev.exe. It takes revision from path and create file from your own template. You can use it as prebuild command.

TortoiseSVN中有一个名为SubWCRev.exe的简单工具。它需要从路径进行修订并从您自己的模板创建文件。您可以将它用作prebuild命令。

#4


2  

Automatically update the file as part of building/deploying the release.

在构建/部署版本时自动更新文件。

#5


1  

On the one project where I had a reason do this, I cheated: it calls svnversion on itself when it starts up.

在我有理由这样做的一个项目中,我作弊:它在启动时调用自身的svnversion。

#6


1  

As alexander said, one way is to update the revision as part of the build process.

正如亚历山大所说,一种方法是将修订更新为构建过程的一部分。

One method of doing this is to take your release builds from an automated build process triggered from your version control checkin, by using a tool such as buildbot.

这样做的一种方法是使用诸如buildbot之类的工具从版本控制签入触发的自动构建过程中获取发布版本。

A scenario might be to trigger the automated build using the post-hook script on your subversion repository. This causes your buildbot to update to the most recently checked in revision. Your build script (eg. Makefile) would use 'svnversion' (or 'svn info' and grep) to read the repository revision and write it into a header file before the build takes place.

方案可能是使用subversion存储库上的post-hook脚本触发自动构建。这会导致您的buildbot更新到最近签入的修订版本。您的构建脚本(例如Makefile)将使用'svnversion'(或'svn info'和grep)来读取存储库修订版,并在构建之前将其写入头文件。

After the successful build, automatically check this file back into the repository with a suitable comment about the release version.

成功构建之后,自动将此文件重新检入存储库,并提供有关发布版本的适当注释。