Class: Gitolite::Git::Adapter
- Inherits:
-
Object
- Object
- Gitolite::Git::Adapter
- Defined in:
- lib/gitolite/grit/adapter.rb
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_BRANCH =
'master'
- Git_command__push_mutex =
Mutex.new
Instance Method Summary collapse
- #branches ⇒ Object
- #file_content(path) ⇒ Object
-
#initialize(repo_dir, branch = 'master') ⇒ Adapter
constructor
A new instance of Adapter.
- #ls_r(depth = nil, opts = {}) ⇒ Object
- #path_exists?(path) ⇒ Boolean
- #pull ⇒ Object
- #push ⇒ Object
- #push_to_mirror_repo(mirror_repo) ⇒ Object
Constructor Details
#initialize(repo_dir, branch = 'master') ⇒ Adapter
Returns a new instance of Adapter.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/gitolite/grit/adapter.rb', line 9 def initialize(repo_dir,branch='master') @repo_dir = repo_dir @branch = branch @grit_repo = nil begin @grit_repo = ::Grit::Repo.new(repo_dir) rescue ::Grit::NoSuchPathError repo_name = repo_dir.split("/").last.gsub("\.git","") #TODO: change to usage error raise Error::NotFound, "Repo (#{repo_name}) - path '#{repo_dir}' does not exist" rescue => e raise e end end |
Instance Method Details
#branches ⇒ Object
24 25 26 |
# File 'lib/gitolite/grit/adapter.rb', line 24 def branches() @grit_repo.branches.map{|h|h.name} end |
#file_content(path) ⇒ Object
37 38 39 40 |
# File 'lib/gitolite/grit/adapter.rb', line 37 def file_content(path) tree_or_blob = tree/path tree_or_blob && tree_or_blob.kind_of?(::Grit::Blob) && tree_or_blob.data end |
#ls_r(depth = nil, opts = {}) ⇒ Object
28 29 30 31 |
# File 'lib/gitolite/grit/adapter.rb', line 28 def ls_r(depth=nil,opts={}) tree_contents = tree.contents ls_r_aux(depth,tree_contents,opts) end |
#path_exists?(path) ⇒ Boolean
33 34 35 |
# File 'lib/gitolite/grit/adapter.rb', line 33 def path_exists?(path) not (tree/path).nil? end |
#pull ⇒ Object
54 55 56 |
# File 'lib/gitolite/grit/adapter.rb', line 54 def pull() git_command(:pull,"origin",@branch) end |
#push ⇒ Object
42 43 44 45 46 |
# File 'lib/gitolite/grit/adapter.rb', line 42 def push() Git_command__push_mutex.synchronize do git_command(:push,"origin", "#{@branch}:refs/heads/#{@branch}") end end |
#push_to_mirror_repo(mirror_repo) ⇒ Object
48 49 50 |
# File 'lib/gitolite/grit/adapter.rb', line 48 def push_to_mirror_repo(mirror_repo) git_command(:push,"--mirror",mirror_repo) end |