From 4524ba20b804dacccbaca3c37e781adc82c5e0d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 28 Mar 2013 21:57:38 +0200 Subject: [PATCH] First step with rugged --- Gemfile | 1 + Gemfile.lock | 2 ++ app/models/repository.rb | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 035942f..f8aa096 100644 --- a/Gemfile +++ b/Gemfile @@ -22,6 +22,7 @@ gem 'omniauth-twitter' gem 'omniauth-github' # Extracting information from a git repository +gem 'rugged', '~> 0.17.0.b7' gem "gitlab-grit", '~> 1.0.0', require: 'grit' gem 'grit_ext', '~> 0.8.1' diff --git a/Gemfile.lock b/Gemfile.lock index fca9271..0c96c35 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -397,6 +397,7 @@ GEM ruby-progressbar (1.0.2) rubyntlm (0.1.1) rubyzip (0.9.9) + rugged (0.17.0.b7) sanitize (2.0.3) nokogiri (>= 1.4.4, < 1.6) sass (3.2.7) @@ -565,6 +566,7 @@ DEPENDENCIES redcarpet (~> 2.2.2) redis-rails rspec-rails + rugged (~> 0.17.0.b7) sass-rails (~> 3.2.5) sdoc seed-fu diff --git a/app/models/repository.rb b/app/models/repository.rb index 934c1a6..93ead9e 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -34,6 +34,10 @@ class Repository @repo ||= Grit::Repo.new(path_to_repo) end + def rugged + @rugged ||= Rugged::Repository.new(path_to_repo) + end + def commit(commit_id = nil) Commit.find_or_first(repo, commit_id, root_ref) end @@ -64,17 +68,17 @@ class Repository # Returns an Array of branch names def branch_names - repo.branches.collect(&:name).sort + branches.map(&:name).sort end # Returns an Array of Branches def branches - repo.branches.sort_by(&:name) + rugged.branches.sort_by(&:name) end # Returns an Array of tag names def tag_names - repo.tags.collect(&:name).sort.reverse + rugged.tags.sort.reverse end # Returns an Array of Tags -- libgit2 0.21.2