public
Rubygem
Description: Ruby/Git is a Ruby library that can be used to create, read and manipulate Git repositories by wrapping system calls to the git binary.
Homepage: http://jointheconversation.org/rubygit/
Clone URL: git://github.com/schacon/ruby-git.git
Search Repo:
bug fixes
schacon (author)
Sun Mar 23 13:32:52 -0700 2008
commit  ae106e2a3569e5ea874852c613ed060d8e232109
tree    dd6879ca27f80243564787f5d3a43b4901fb3cea
parent  6c4af60f5fc5193b956a4698b604ad96ef3c51c6
...
181
182
183
184
 
 
 
 
 
185
186
187
188
189
190
191
...
190
191
192
 
 
 
 
193
194
195
196
197
198
 
 
 
 
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
 
 
216
217
218
...
181
182
183
 
184
185
186
187
188
189
190
191
192
193
194
195
...
194
195
196
197
198
199
200
201
 
202
 
 
 
203
204
205
206
207
 
 
 
 
 
 
 
 
 
208
209
210
211
212
 
 
213
214
215
216
217
0
@@ -181,7 +181,11 @@
0
       
0
       data
0
     end
0
-
0
+
0
+ def mv(file1, file2)
0
+ command_lines('mv', [file1, file2])
0
+ end
0
+
0
     def full_tree(sha)
0
       command_lines('ls-tree', ['-r', sha.to_s])
0
     end
0
0
0
0
0
@@ -190,29 +194,24 @@
0
       full_tree(sha).size
0
     end
0
 
0
+ def change_head_branch(branch_name)
0
+ command('symbolic-ref', ['HEAD', "refs/heads/#{branch_name}"])
0
+ end
0
+
0
     def branches_all
0
- head = File.read(File.join(@git_dir, 'HEAD'))
0
       arr = []
0
-
0
- if m = /ref: refs\/heads\/(.*)/.match(head)
0
- current = m[1]
0
+ command_lines('branch', '-a').each do |b|
0
+ current = false
0
+ current = true if b[0, 2] == '* '
0
+ arr << [b.gsub('* ', '').strip, current]
0
       end
0
- arr += list_files('heads').map { |f| [f, f == current] }
0
- arr += list_files('remotes').map { |f| [f, false] }
0
-
0
- #command_lines('branch', '-a').each do |b|
0
- # current = false
0
- # current = true if b[0, 2] == '* '
0
- # arr << [b.gsub('* ', '').strip, current]
0
- #end
0
-
0
       arr
0
     end
0
 
0
     def list_files(ref_dir)
0
       dir = File.join(@git_dir, 'refs', ref_dir)
0
- files = nil
0
- Dir.chdir(dir) { files = Dir.glob('**/*').select { |f| File.file?(f) } }
0
+ files = []
0
+ Dir.chdir(dir) { files = Dir.glob('**/*').select { |f| File.file?(f) } } rescue nil
0
       files
0
     end
0
     

Comments

    No one has commented yet.