public
Fork of Caged/gitnub
Description: A Gitk-like application written in RubyCocoa that looks like it belongs on a Mac. See the wiki for downloads and screenshots.
Homepage: http://alternateidea.com
Clone URL: git://github.com/dustin/gitnub.git
Search Repo:
Look upwards until we find a directory that looks like a supported repo.
dustin (author)
Thu Mar 20 18:49:22 -0700 2008
commit  4c5b5904d9b5776d4b0b8d13ca5ad66059f2373f
tree    9e2ee47673367e82e0147727131de99bbcf32f39
parent  8048872c76a0bdc44eb2a5855689106fc9082d67
...
100
101
102
 
 
103
104
 
 
 
 
 
 
 
 
105
106
 
107
108
 
109
110
 
111
112
...
100
101
102
103
104
105
 
106
107
108
109
110
111
112
113
114
 
115
116
 
117
118
119
120
121
122
0
@@ -100,14 +100,24 @@
0
   # Detect a repo type and open it.
0
   def RCSetta::open(path)
0
     epath = File.expand_path path
0
+ RCSetta::search_up epath.split(/\//)
0
+ end
0
 
0
- driver = SCM_DRIVERS.detect{|p, c| File.exist?(File.join(epath, p))}
0
+ private
0
+
0
+ # Look upwards until we find something we understand, or we can't go up any
0
+ # further.
0
+ def RCSetta::search_up(paths)
0
+ raise "Cannot detect repo type from #{path}" if paths.empty?
0
+ path=paths.join '/'
0
+ driver = SCM_DRIVERS.detect{|p, c| File.exist?(File.join(path, p))}
0
     if driver
0
- driver.last.new epath
0
+ driver.last.new path
0
     else
0
- raise "Cannot detect repo type from #{path}"
0
+ RCSetta::search_up(paths[0..-2])
0
     end
0
   end
0
+
0
 
0
 end

Comments

  • libc Sat Apr 26 18:16:55 -0700 2008

    What about `git rev-parse—git-dir` ?

  • dustin Sat Apr 26 19:21:38 -0700 2008

    Makes sense, but the goal was to detect what revision control system is in use so I can load the proper driver in an easy and generic way.
    I could also just execute that as well as `hg root`. It’d be slower, but in one of those kind of undetectable ways.