プロジェクト

全般

プロフィール

Vote #79520

完了

Redmine::VERSION::revision may return wrong value

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Administration_8
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
8
version_id:
127
issue_org_id:
29601
author_id:
362529
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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




               
https://svn.redmine.org/redmine/tags/3.4.3
^/tags/3.4.3

https://svn.redmine.org/redmine
e93f8b46-1217-0410-a6f0-8f06a7374b81


/path/to/redmine
normal
infinity

         
jplang
2017-10-15T19:54:11.195354Z



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

journals

I posted a patch file.
--------------------------------------------------------------------------------
I have confirmed the issue.

---

Now the current directory is the working copy of /branches/4.0-stable branch.

<pre>
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)
</pre>

The latest change is !r18591.

<pre>
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).
</pre>

But the admin/info page says the revision is !r18593.

!{width: 270px; border: 1px solid #ccc;}.admin-info-before@2x.png!

After applying the patch, admin/info page reports the correct revision number !r18591.

!{width: 270px; border: 1px solid #ccc;}.admin-info-after@2x.png!

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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.

<pre>
$ 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
</pre>

<pre><code class="diff">
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
</code></pre>
--------------------------------------------------------------------------------
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":http://mail-archives.apache.org/mod_mbox/subversion-dev/201502.mbox/%3c54ECA043.2080603@wandisco.com%3e).

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.

--------------------------------------------------------------------------------
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":http://mail-archives.apache.org/mod_mbox/subversion-dev/201502.mbox/%3c54ECA043.2080603@wandisco.com%3e).

Thanks, I didn't know that the option is only available in Subversion 1.9. The patch I posted should not be applied.
--------------------------------------------------------------------------------
Committed the patch. Thank you for your contribution.
--------------------------------------------------------------------------------
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":http://mail-archives.apache.org/mod_mbox/subversion-dev/201502.mbox/%3c54ECA043.2080603@wandisco.com%3e).
>
> 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.
--------------------------------------------------------------------------------

Admin Redmine さんが4年以上前に更新

  • カテゴリAdministration_8 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0