Skip to content
Snippets Groups Projects
Commit aa5074cc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Replace grit with rugged

parent b7a6154e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -38,7 +38,7 @@ gem 'whenever', require: false
gem 'stamp'
 
# Git support
gem 'grit'
gem 'rugged', '~> 0.17.0.b7'
 
# Pagination
gem 'kaminari'
Loading
Loading
Loading
Loading
@@ -87,10 +87,6 @@ GEM
foreman (0.60.2)
thor (>= 0.13.6)
gitlab_ci_meta (1.0)
grit (2.5.0)
diff-lcs (~> 1.1)
mime-types (~> 1.15)
posix-spawn (~> 0.3.6)
growl (1.0.3)
guard (1.3.2)
listen (>= 0.4.2)
Loading
Loading
@@ -129,7 +125,6 @@ GEM
orm_adapter (0.4.0)
pg (0.14.1)
polyglot (0.3.3)
posix-spawn (0.3.6)
pry (0.9.10)
coderay (~> 1.0.5)
method_source (~> 0.8)
Loading
Loading
@@ -187,6 +182,7 @@ GEM
railties (>= 3.0)
rspec (~> 2.11.0)
rubyzip (0.9.9)
rugged (0.17.0.b7)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
Loading
Loading
@@ -263,7 +259,6 @@ DEPENDENCIES
font-awesome-sass-rails (~> 3.0.0)
foreman
gitlab_ci_meta
grit
growl
guard-rspec
haml-rails
Loading
Loading
@@ -279,6 +274,7 @@ DEPENDENCIES
rb-fsevent
rb-inotify
rspec-rails
rugged (~> 0.17.0.b7)
sass-rails (~> 3.2.3)
settingslogic
shoulda-matchers
Loading
Loading
class ApplicationController < ActionController::Base
protect_from_forgery
 
rescue_from Grit::InvalidGitRepositoryError do |exception|
@error = "Project path is not a git repository"
render "errors/show", status: 500
end
def authenticate_token!
unless project.valid_token?(params[:token])
return head(403)
Loading
Loading
Loading
Loading
@@ -64,7 +64,7 @@ class Build < ActiveRecord::Base
end
 
def git_author_name
commit.author.name
commit.author[:name]
rescue
nil
end
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ class Project < ActiveRecord::Base
 
def repo_present?
repo
rescue Grit::NoSuchPathError, Grit::InvalidGitRepositoryError
rescue
errors.add(:path, 'Project path is not a git repository')
false
end
Loading
Loading
@@ -109,11 +109,21 @@ class Project < ActiveRecord::Base
end
 
def repo
@repo ||= Grit::Repo.new(path)
@repo ||= Rugged::Repository.new(path)
end
 
def last_commit(ref = 'master')
repo.commits(ref, 1).first
branch = find_branch_by_name(ref)
if branch
repo.lookup(branch.target)
else
repo.lookup(ref)
end
end
def find_branch_by_name(name)
repo.branches.find { |branch| branch.name == name }
end
 
def tracked_refs
Loading
Loading
@@ -149,23 +159,3 @@ end
# token :string(255)
# default_ref :string(255)
#
# == Schema Information
#
# Table name: projects
#
# id :integer(4) not null, primary key
# name :string(255) not null
# path :string(255) not null
# timeout :integer(4) default(1800), not null
# scripts :text default(""), not null
# created_at :datetime not null
# updated_at :datetime not null
# token :string(255)
# default_ref :string(255)
# gitlab_url :string(255)
# always_build :boolean(1) default(FALSE), not null
# polling_interval :integer(4)
# public :boolean(1) default(FALSE), not null
#
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment