First step with rugged
This commit is contained in:
parent
21191318ae
commit
4524ba20b8
3 changed files with 10 additions and 3 deletions
1
Gemfile
1
Gemfile
|
@ -22,6 +22,7 @@ gem 'omniauth-twitter'
|
||||||
gem 'omniauth-github'
|
gem 'omniauth-github'
|
||||||
|
|
||||||
# Extracting information from a git repository
|
# Extracting information from a git repository
|
||||||
|
gem 'rugged', '~> 0.17.0.b7'
|
||||||
gem "gitlab-grit", '~> 1.0.0', require: 'grit'
|
gem "gitlab-grit", '~> 1.0.0', require: 'grit'
|
||||||
gem 'grit_ext', '~> 0.8.1'
|
gem 'grit_ext', '~> 0.8.1'
|
||||||
|
|
||||||
|
|
|
@ -397,6 +397,7 @@ GEM
|
||||||
ruby-progressbar (1.0.2)
|
ruby-progressbar (1.0.2)
|
||||||
rubyntlm (0.1.1)
|
rubyntlm (0.1.1)
|
||||||
rubyzip (0.9.9)
|
rubyzip (0.9.9)
|
||||||
|
rugged (0.17.0.b7)
|
||||||
sanitize (2.0.3)
|
sanitize (2.0.3)
|
||||||
nokogiri (>= 1.4.4, < 1.6)
|
nokogiri (>= 1.4.4, < 1.6)
|
||||||
sass (3.2.7)
|
sass (3.2.7)
|
||||||
|
@ -565,6 +566,7 @@ DEPENDENCIES
|
||||||
redcarpet (~> 2.2.2)
|
redcarpet (~> 2.2.2)
|
||||||
redis-rails
|
redis-rails
|
||||||
rspec-rails
|
rspec-rails
|
||||||
|
rugged (~> 0.17.0.b7)
|
||||||
sass-rails (~> 3.2.5)
|
sass-rails (~> 3.2.5)
|
||||||
sdoc
|
sdoc
|
||||||
seed-fu
|
seed-fu
|
||||||
|
|
|
@ -34,6 +34,10 @@ class Repository
|
||||||
@repo ||= Grit::Repo.new(path_to_repo)
|
@repo ||= Grit::Repo.new(path_to_repo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def rugged
|
||||||
|
@rugged ||= Rugged::Repository.new(path_to_repo)
|
||||||
|
end
|
||||||
|
|
||||||
def commit(commit_id = nil)
|
def commit(commit_id = nil)
|
||||||
Commit.find_or_first(repo, commit_id, root_ref)
|
Commit.find_or_first(repo, commit_id, root_ref)
|
||||||
end
|
end
|
||||||
|
@ -64,17 +68,17 @@ class Repository
|
||||||
|
|
||||||
# Returns an Array of branch names
|
# Returns an Array of branch names
|
||||||
def branch_names
|
def branch_names
|
||||||
repo.branches.collect(&:name).sort
|
branches.map(&:name).sort
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an Array of Branches
|
# Returns an Array of Branches
|
||||||
def branches
|
def branches
|
||||||
repo.branches.sort_by(&:name)
|
rugged.branches.sort_by(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an Array of tag names
|
# Returns an Array of tag names
|
||||||
def tag_names
|
def tag_names
|
||||||
repo.tags.collect(&:name).sort.reverse
|
rugged.tags.sort.reverse
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an Array of Tags
|
# Returns an Array of Tags
|
||||||
|
|
Loading…
Reference in a new issue