summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-01 17:00:28 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-10-01 17:00:28 +0300
commitae9dd6276267e0df2d9c2da3b89393e4ee212175 (patch)
tree4db4314bd54eda3bce6b3c67b719f1f5097fb68a /app/models
parente219cf7246c6a0495e4507deaffeba11e79f13b8 (diff)
downloadgitlab-ce-ae9dd6276267e0df2d9c2da3b89393e4ee212175.tar.gz
Update code to work with gitlab_git 3
Diffstat (limited to 'app/models')
-rw-r--r--app/models/repository.rb9
-rw-r--r--app/models/tree.rb24
2 files changed, 23 insertions, 10 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index aeec48ee5cc..734d060095e 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1,14 +1,19 @@
class Repository
include Gitlab::ShellAdapter
- attr_accessor :raw_repository
+ attr_accessor :raw_repository, :path_with_namespace
def initialize(path_with_namespace, default_branch)
- @raw_repository = Gitlab::Git::Repository.new(path_with_namespace, default_branch)
+ @path_with_namespace = path_with_namespace
+ @raw_repository = Gitlab::Git::Repository.new(path_to_repo)
rescue Gitlab::Git::Repository::NoRepository
nil
end
+ def path_to_repo
+ @path_to_repo ||= File.join(Gitlab.config.gitlab_shell.repos_path, path_with_namespace + ".git")
+ end
+
def exists?
raw_repository
end
diff --git a/app/models/tree.rb b/app/models/tree.rb
index 042050527c1..5fbad19b468 100644
--- a/app/models/tree.rb
+++ b/app/models/tree.rb
@@ -1,17 +1,25 @@
class Tree
- attr_accessor :raw
+ attr_accessor :entries, :readme
- def initialize(repository, sha, ref = nil, path = nil)
- @raw = Gitlab::Git::Tree.new(repository, sha, ref, path)
+ def initialize(repository, sha, path = '/')
+ path = '/' if path.blank?
+ git_repo = repository.raw_repository
+ @entries = Gitlab::Git::Tree.where(git_repo, sha, path)
+
+ if readme_tree = @entries.find(&:readme?)
+ @readme = Gitlab::Git::Blob.find(git_repo, sha, readme_tree.name)
+ end
end
- def method_missing(m, *args, &block)
- @raw.send(m, *args, &block)
+ def trees
+ @entries.select(&:dir?)
end
- def respond_to?(method)
- return true if @raw.respond_to?(method)
+ def blobs
+ @entries.select(&:file?)
+ end
- super
+ def submodules
+ @entries.select(&:submodule?)
end
end