class Gitolite::Git::FileAccess
Constants
- Change_dir_mutex
Public Instance Methods
add_file(file_rel_path,content)
click to toggle source
# File lib/gitolite/grit/file_access.rb, line 24 def add_file(file_rel_path,content) content ||= String.new file_path = qualified_path(file_rel_path) chdir_and_checkout do File.open(file_path,"w+"){|f|f << content} git_command(:add,file_path) end end
commit(commit_msg)
click to toggle source
# File lib/gitolite/grit/file_access.rb, line 42 def commit(commit_msg) #TODO is chdir_and_checkout needed chdir_and_checkout do @grit_repo.commit_index(commit_msg) end end
remove_file(file_rel_path)
click to toggle source
# File lib/gitolite/grit/file_access.rb, line 33 def remove_file(file_rel_path) file_path = qualified_path(file_rel_path) chdir_and_checkout do if File.file?(file_path) git_command(:rm,file_path) end end end
Private Instance Methods
chdir_and_checkout(branch=nil) { || ... }
click to toggle source
# File lib/gitolite/grit/file_access.rb, line 57 def chdir_and_checkout(branch=nil,&block) Change_dir_mutex.synchronize do branch ||= @branch Dir.chdir(@repo_dir) do current_head = @grit_repo.head.name git_command(:checkout,branch) unless current_head == branch return unless block yield unless current_head == branch git_command(:checkout,current_head) end end end end
qualified_path(file_rel_path)
click to toggle source
# File lib/gitolite/grit/file_access.rb, line 51 def qualified_path(file_rel_path) "#{@repo_dir}/#{file_rel_path}" end