public
Description: Piston is a utility that eases vendor branch management. This repository is a complete reimplementation of Piston to provide different backends, depending on the repositories and working copies you pistonize from.
Homepage: http://piston.rubyforge.org/
Clone URL: git://github.com/francois/piston.git
Search Repo:
Use new algorithm to find Git working copies.

Do a Dir.chdir instead of doing a git status DIR, which doesn't work.
francois (author)
Sat Mar 22 19:57:46 -0700 2008
commit  a3c673d0a7b6118f3e0784ddfede04e1510b8b82
tree    9216f98e811fcbd14de6169b6b74fe12e36e07d7
parent  c81aa59f7c99f22b181a27899af6a9eb7944bb91
...
14
15
16
17
18
19
 
 
 
 
 
 
 
 
20
 
 
21
22
23
 
 
 
24
25
26
...
14
15
16
 
 
 
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
0
@@ -14,13 +14,23 @@
0
         def understands_dir?(dir)
0
           path = dir
0
           begin
0
- while path.parent && path.to_s != "/"
0
- response = git(:status, path)
0
- return true if response =~ /# On branch /
0
+ begin
0
+ logger.debug {"git status on #{path}"}
0
+ Dir.chdir(path) do
0
+ response = git(:status)
0
+ return true if response =~ /# On branch /
0
+ end
0
+ rescue Errno::ENOENT
0
+ # NOP, we assume this is simply because the folder hasn't been created yet
0
               path = path.parent
0
+ retry unless path.to_s == "/"
0
+ return false
0
             end
0
           rescue BadCommand
0
             # NOP, as we return false below
0
+ rescue Piston::Git::Client::CommandError
0
+ # This is certainly not a Git repository
0
+ false
0
           end
0
 
0
           false
...
6
7
8
9
 
 
10
11
12
...
16
17
18
19
20
21
 
 
 
 
 
22
23
24
...
6
7
8
 
9
10
11
12
13
...
17
18
19
 
 
 
20
21
22
23
24
25
26
27
0
@@ -6,7 +6,8 @@
0
   end
0
 
0
   def test_does_git_status_on_directory
0
- Piston::Git::WorkingCopy.expects(:git).with(:status, @dir).returns("# On branch master
0
+ Dir.expects(:chdir).with(@dir).yields
0
+ Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
0
 nothing to commit (working directory clean)
0
 ")
0
     assert Piston::Git::WorkingCopy.understands_dir?(@dir)
0
@@ -16,9 +17,11 @@
0
     @wc = @dir
0
     @tmp = @wc.parent
0
     @root = @tmp.parent
0
- Piston::Git::WorkingCopy.expects(:git).with(:status, @wc)
0
- Piston::Git::WorkingCopy.expects(:git).with(:status, @tmp)
0
- Piston::Git::WorkingCopy.expects(:git).with(:status, @root).returns("# On branch master
0
+
0
+ Dir.expects(:chdir).with(@dir).raises(Errno::ENOENT)
0
+ Dir.expects(:chdir).with(@tmp).raises(Errno::ENOENT)
0
+ Dir.expects(:chdir).with(@root).yields
0
+ Piston::Git::WorkingCopy.expects(:git).with(:status).returns("# On branch master
0
 nothing to commit (working directory clean)
0
 ")
0
     assert Piston::Git::WorkingCopy.understands_dir?(@dir)

Comments

    No one has commented yet.