[Bug #919] tool/file2lastrev.rb$B$G%(%i!<(B

Bug #919: tool/file2lastrev.rbe$B$G%(%i!<e(B
http://redmine.ruby-lang.org/issues/show/919

e$B5/I<<Te(B: Tadashi S.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$BC4Ev<Te(B: Yuki S., Target version: 1.9.x

e$B%=!<%9$H0c$&%G%#%l%/%H%j$Ge(Btrunke$B$re(Bmakee$B$7$h$&$H$9$k$H!"e(B
tool/file2lastrev.rbe$B$G%(%i!<$,=P$Fe(Bmakee$B$G$-$^$;$s!#e(B

$ make
ruby …/tool/file2lastrev.rb --revision.h “…” > “…/revision.h.tmp”
svn: ‘.’ is not a working copy
…/tool/file2lastrev.rb:34:in `get_revisions’: last revision not found
(RuntimeError)
from …/tool/file2lastrev.rb:70
make: *** […/revision.h] e$B%(%i!<e(B 1

e$B0l1~2<$N$GD>$j$^$7$?$,!“HFMQ@-$,$”$k$N$+@5D><+?.$,$"$j$^$;$s!#e(B

Index: tool/file2lastrev.rb

— tool/file2lastrev.rb (revision 20922)
+++ tool/file2lastrev.rb (working copy)
@@ -10,8 +10,8 @@

path = target_path.directory? ? target_path : target_path.parent
begin

  • return :svn, target_path.relative_path_from(path) if
    File.directory?(“#{path}/.svn”)
  • return :git, target_path.relative_path_from(path) if
    File.directory?(“#{path}/.git”)
  • return :svn, target_path.relative_path_from(Pathname.pwd) if
    File.directory?(“#{path}/.svn”)
  • return :git, target_path.relative_path_from(Pathname.pwd) if
    File.directory?(“#{path}/.git”)
    path, orig = path.parent, path
    end until path == orig
    raise VCSNotFoundError, “does not seem to be under a vcs”

e$B!!$5$5$@$G$9!%e(B

Tadashi S. wrote::

e$B0l1~2<$N$GD>$j$^$7$?$,!“HFMQ@-$,$”$k$N$+@5D><+?.$,$"$j$^$;$s!#e(B

e$B!!;d$O$h$/$o$+$s$J$+$C$?$N$G!$4JC1$K$7$F$_$^$7$?!%$G$b!$$J$s$G%U%k%Q%9$Ke(B
e$B$9$k$s$@$m$&!%e(B

Index: tool/file2lastrev.rb

— tool/file2lastrev.rb (e$B%j%S%8%g%se(B 20922)
+++ tool/file2lastrev.rb (e$B:n6H%3%T!<e(B)
@@ -6,12 +6,15 @@
class VCSNotFoundError < RuntimeError; end

def detect_vcs(path)

  • target_path = Pathname(File.expand_path(path))
  • target_path = Pathname(File.expand_path(path))

  • path = target_path.directory? ? target_path : target_path.parent

  • path = Pathname(File.dirname($0)).parent
  • path = target_path.directory? ? target_path : target_path.parent
    begin
  • return :svn, target_path.relative_path_from(path) if
    File.directory?("#{pat
    h}/.svn")
  • return :git, target_path.relative_path_from(path) if
    File.directory?("#{pat
    h}/.git")
  • return :svn, path if File.directory?("#{path}/.svn")
  • return :git, path if File.directory?("#{path}/.git")
    path, orig = path.parent, path
    end until path == orig
    raise VCSNotFoundError, “does not seem to be under a vcs”

Yuguie$B$G$9!#e(B

e$B$9$_$^$;$s!#;d$N%P%0$G$9!#e(B

On 12/23/08 7:12 AM, SASADA Koichi wrote:

Pathname(File.dirname($0)).parent

e$B$"!"$=$&$+!#$3$l$G9T$1$=$&$G$9!#$"$j$,$H$&$4$6$$$^$9!#e(B

e$B%A%1%C%He(B #919 e$B$,99?7$5$l$^$7$?!#e(B (by Yuki S.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

Applied in changeset r20936.

http://redmine.ruby-lang.org/issues/show/919