Defect #29601
closedRedmine::VERSION::revision may return wrong value
0%
Description
Currently, Redmine::VERSION::revision return 'Revision'.
$ ruby bin/about Environment: Redmine version 3.4.3.stable.17480 Ruby version 2.2.5-p319 (2016-04-26) [x86_64-darwin17] Rails version 4.2.8 Environment production Database adapter SQLite SCM: Subversion 1.9.7 Git 2.15.2 Filesystem Redmine plugins: no plugin installed
But, Revision of checkout URL is 'Last Changed Rev'.
$ svn info --xml
<?xml version="1.0" encoding="UTF-8"?>
<info>
<entry
path="."
revision="17480"
kind="dir"> <!-- Currently shown Redmine::VERSION::revision (17480) -->
<url>https://svn.redmine.org/redmine/tags/3.4.3</url>
<relative-url>^/tags/3.4.3</relative-url>
<repository>
<root>https://svn.redmine.org/redmine</root>
<uuid>e93f8b46-1217-0410-a6f0-8f06a7374b81</uuid>
</repository>
<wc-info>
<wcroot-abspath>/path/to/redmine</wcroot-abspath>
<schedule>normal</schedule>
<depth>infinity</depth>
</wc-info>
<commit
revision="17010"> <!-- Revision of checkout URL (17010) -->
<author>jplang</author>
<date>2017-10-15T19:54:11.195354Z</date>
</commit>
</entry>
</info>
I would like to change it as follows.
Index: lib/redmine/version.rb
===================================================================
diff --git a/trunk/lib/redmine/version.rb b/trunk/lib/redmine/version.rb
--- a/trunk/lib/redmine/version.rb (revision 17480)
+++ b/trunk/lib/redmine/version.rb (working copy)
@@ -18,7 +18,7 @@
if File.directory?(File.join(Rails.root, '.svn'))
begin
path = Redmine::Scm::Adapters::AbstractAdapter.shell_quote(Rails.root.to_s)
- if `#{Redmine::Scm::Adapters::SubversionAdapter.client_command} info --xml #{path}` =~ /revision="(\d+)"/
+ if `#{Redmine::Scm::Adapters::SubversionAdapter.client_command} info --xml #{path}` =~ /commit\s+revision="(\d+)"/
return $1.to_i
end
rescue
Files
Updated by Yuichi HARADA over 6 years ago
- File redmine_version_revision_change_to_last_changed_rev.patch redmine_version_revision_change_to_last_changed_rev.patch added
I posted a patch file.
Updated by Go MAEDA over 5 years ago
- File admin-info-before@2x.png admin-info-before@2x.png added
- File admin-info-after@2x.png admin-info-after@2x.png added
- Status changed from New to Confirmed
- Target version set to 4.2.0
I have confirmed the issue.
Now the current directory is the working copy of /branches/4.0-stable branch.
laphroaig:4.0-stable maeda$ svn info Path: . Working Copy Root Path: /Users/maeda/redmines/4.0-stable URL: https://svn.redmine.org/redmine/branches/4.0-stable Relative URL: ^/branches/4.0-stable Repository Root: https://svn.redmine.org/redmine Repository UUID: e93f8b46-1217-0410-a6f0-8f06a7374b81 Revision: 18593 Node Kind: directory Schedule: normal Last Changed Author: maeda Last Changed Rev: 18591 Last Changed Date: 2019-10-04 08:30:08 +0900 (Fri, 04 Oct 2019)
The latest change is r18591.
laphroaig:4.0-stable maeda$ svn log | head ------------------------------------------------------------------------ r18591 | maeda | 2019-10-04 08:30:08 +0900 (Fri, 04 Oct 2019) | 2 lines Merged r18589 from trunk to 4.0-stable (#32110). ------------------------------------------------------------------------ r18590 | maeda | 2019-10-04 08:28:00 +0900 (Fri, 04 Oct 2019) | 2 lines Merged r18588 from trunk to 4.0-stable (#32189).
But the admin/info page says the revision is r18593.
After applying the patch, admin/info page reports the correct revision number r18591.
Updated by Go MAEDA over 5 years ago
- Subject changed from When using 'svn checkout' to acquire Redmine, Redmine::VERSION::revision should be 'Last Changed Rev' to Redmine::VERSION::revision may return wrong value
Updated by Go MAEDA over 5 years ago
We don't have to parse XML with regexp if we use `svn info --show-item last-changed-revision`
. The command simply returns the number of last changed revision without any other unnecessary data.
$ svn info Path: . Working Copy Root Path: /Users/maeda/redmines/4.0-stable URL: https://svn.redmine.org/redmine/branches/4.0-stable Relative URL: ^/branches/4.0-stable Repository Root: https://svn.redmine.org/redmine Repository UUID: e93f8b46-1217-0410-a6f0-8f06a7374b81 Revision: 18593 Node Kind: directory Schedule: normal Last Changed Author: maeda Last Changed Rev: 18591 Last Changed Date: 2019-10-04 08:30:08 +0900 (Fri, 04 Oct 2019) $ svn info --show-item last-changed-revision 18591
diff --git a/lib/redmine/version.rb b/lib/redmine/version.rb
index 03eeadef9..40122ebd6 100644
--- a/lib/redmine/version.rb
+++ b/lib/redmine/version.rb
@@ -20,9 +20,7 @@ module Redmine
if File.directory?(File.join(Rails.root, '.svn'))
begin
path = Redmine::Scm::Adapters::AbstractAdapter.shell_quote(Rails.root.to_s)
- if `#{Redmine::Scm::Adapters::SubversionAdapter.client_command} info --xml #{path}` =~ /revision="(\d+)"/
- return $1.to_i
- end
+ return Integer(`#{Redmine::Scm::Adapters::SubversionAdapter.client_command} info --show-item last-changed-revision #{path}`)
rescue
# Could not find the current revision
end
Updated by Mischa The Evil over 5 years ago
Go MAEDA wrote:
We don't have to parse XML with regexp if we use
`svn info --show-item last-changed-revision`
.
That's nice indeed. The issue however could be that by utilizing svn info --show item ...
we effectively drop support for Subversion <1.9 because that command is introduced only as part of the 1.9 branch (see the Subversion Mailinglist thread).
Given the circumstances, I don't think that this change in approach of getting the revision number with the corresponding performance increase is worth the raise of compatibility requirements for the Subversion binary.
Updated by Go MAEDA over 5 years ago
Mischa The Evil wrote:
The issue however could be that by utilizing
svn info --show item ...
we effectively drop support for Subversion <1.9 because that command is introduced only as part of the 1.9 branch (see the Subversion Mailinglist thread).
Thanks, I didn't know that the option is only available in Subversion 1.9. The patch I posted should not be applied.
Updated by Go MAEDA over 5 years ago
- Status changed from Confirmed to Closed
- Assignee set to Go MAEDA
- Target version changed from 4.2.0 to 4.1.0
- Resolution set to Fixed
Committed the patch. Thank you for your contribution.
Updated by Mischa The Evil over 5 years ago
Go MAEDA wrote:
Mischa The Evil wrote:
The issue however could be that by utilizing
svn info --show item ...
we effectively drop support for Subversion <1.9 because that command is introduced only as part of the 1.9 branch (see the Subversion Mailinglist thread).Thanks, I didn't know that the option is only available in Subversion 1.9.
FWIW and FTR: what I meant to say is that the svn info --show item ...
command is only available in Subversion 1.9 and up, not that it is 1.9 only.