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

**URL:** <https://www.ruby-forum.com/t/bug-919-tool-file2lastrev-rb-b-g-i-b/156197>\
**Category:** Development\
**Created:** [December 22, 2008, 5:54pm UTC](https://www.ruby-forum.com/t/bug-919-tool-file2lastrev-rb-b-g-i-b/156197 "2008-12-22T17:54:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sugie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sugie](https://www.ruby-forum.com/u/sugie)\
**Post date:** [December 22, 2008, 5:54pm UTC](https://www.ruby-forum.com/t/bug-919-tool-file2lastrev-rb-b-g-i-b/156197/1 "2008-12-22T17:54:30Z")

</div>

Bug #919: tool/file2lastrev.rbe$B$G%(%i!\<e(B  
[http://redmine.ruby-lang.org/issues/show/919](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”

---

<div class="post-metadata">

**Author:** ![sugie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sugie](https://www.ruby-forum.com/u/sugie)\
**Post date:** [December 22, 2008, 11:21pm UTC](https://www.ruby-forum.com/t/bug-919-tool-file2lastrev-rb-b-g-i-b/156197/2 "2008-12-22T23:21:20Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![sugie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sugie](https://www.ruby-forum.com/u/sugie)\
**Post date:** [December 23, 2008, 6:29am UTC](https://www.ruby-forum.com/t/bug-919-tool-file2lastrev-rb-b-g-i-b/156197/3 "2008-12-23T06:29:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sugie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/82dd89/32.png) [@sugie](https://www.ruby-forum.com/u/sugie)\
**Post date:** [December 23, 2008, 7:47am UTC](https://www.ruby-forum.com/t/bug-919-tool-file2lastrev-rb-b-g-i-b/156197/4 "2008-12-23T07:47:19Z")

</div>

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](http://redmine.ruby-lang.org/issues/show/919)
