summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-01 17:27:44 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-04-01 17:27:44 +0300
commit9a26e9a0d634c8bb796f0b08f6397d1e343bd4be (patch)
tree83ab649038540b07074cf34ce94eedc21386b84f
parent541d89941014137762dff696c83b3357eba8efeb (diff)
downloadgitlab-ce-9a26e9a0d634c8bb796f0b08f6397d1e343bd4be.tar.gz
Dont init repo on every create(:repo)
-rw-r--r--app/helpers/commits_helper.rb4
-rw-r--r--app/models/gollum_wiki.rb6
-rw-r--r--lib/gitlab/git/commit.rb4
-rw-r--r--spec/factories.rb8
-rw-r--r--spec/models/commit_spec.rb2
-rw-r--r--spec/models/gollum_wiki_spec.rb2
-rw-r--r--spec/support/test_env.rb3
7 files changed, 18 insertions, 11 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 66603c97142..95ca294cd2d 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -147,10 +147,6 @@ module CommitsHelper
protected
- def no_commit_message
- "--no commit message"
- end
-
# Private: Returns a link to a person. If the person has a matching user and
# is a member of the current @project it will link to the team member page.
# Otherwise it will link to the person email as specified in the commit.
diff --git a/app/models/gollum_wiki.rb b/app/models/gollum_wiki.rb
index 647058e8ec9..16e801c1fdb 100644
--- a/app/models/gollum_wiki.rb
+++ b/app/models/gollum_wiki.rb
@@ -90,13 +90,17 @@ class GollumWiki
private
def create_repo!
- if gitlab_shell.add_repository(path_with_namespace)
+ if init_repo(path_with_namespace)
Gollum::Wiki.new(path_to_repo)
else
raise CouldNotCreateWikiError
end
end
+ def init_repo(path_with_namespace)
+ gitlab_shell.add_repository(path_with_namespace)
+ end
+
def commit_details(action, message = nil, title = nil)
commit_message = message || default_message(action, title)
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index d7e1a5ca770..35991a383f6 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -144,6 +144,10 @@ module Gitlab
rescue
true
end
+
+ def no_commit_message
+ "--no commit message"
+ end
end
end
end
diff --git a/spec/factories.rb b/spec/factories.rb
index d904e337350..76bd3ebbf23 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -86,9 +86,9 @@ FactoryGirl.define do
target_branch "master" # pretend bcf03b5d~3
source_branch "stable" # pretend bcf03b5d
st_commits do
- [Commit.new(project.repo.commit('bcf03b5d')),
- Commit.new(project.repo.commit('bcf03b5d~1')),
- Commit.new(project.repo.commit('bcf03b5d~2'))]
+ [Commit.new(project.repository.commit('bcf03b5d')),
+ Commit.new(project.repository.commit('bcf03b5d~1')),
+ Commit.new(project.repository.commit('bcf03b5d~2'))]
end
st_diffs do
project.repo.diff("bcf03b5d~3", "bcf03b5d")
@@ -120,6 +120,7 @@ FactoryGirl.define do
factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff]
trait :on_commit do
+ project factory: :project_with_code
commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
noteable_type "Commit"
end
@@ -129,6 +130,7 @@ FactoryGirl.define do
end
trait :on_merge_request do
+ project factory: :project_with_code
noteable_id 1
noteable_type "MergeRequest"
end
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 7713a33da07..6cf777bec04 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Commit do
- let(:commit) { create(:project).repository.commit }
+ let(:commit) { create(:project_with_code).repository.commit }
describe '#title' do
diff --git a/spec/models/gollum_wiki_spec.rb b/spec/models/gollum_wiki_spec.rb
index 87601683275..aa850dfd0a3 100644
--- a/spec/models/gollum_wiki_spec.rb
+++ b/spec/models/gollum_wiki_spec.rb
@@ -81,7 +81,7 @@ describe GollumWiki do
end
it "raises CouldNotCreateWikiError if it can't create the wiki repository" do
- Gitlab::Shell.any_instance.stub(:add_repository).and_return(false)
+ GollumWiki.any_instance.stub(:init_repo).and_return(false)
expect { GollumWiki.new(project, user).wiki }.to raise_exception(GollumWiki::CouldNotCreateWikiError)
end
end
diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb
index 0f81347dd6b..19be8029a98 100644
--- a/spec/support/test_env.rb
+++ b/spec/support/test_env.rb
@@ -17,11 +17,12 @@ module TestEnv
repos_path = Rails.root.join('tmp', 'test-git-base-path')
Gitlab.config.gitlab_shell.stub(repos_path: repos_path)
- Gitlab::Shell.any_instance.stub(:add_repository) do |path|
+ GollumWiki.any_instance.stub(:init_repo) do |path|
create_temp_repo(File.join(repos_path, "#{path}.git"))
end
Gitlab::Shell.any_instance.stub(
+ add_repository: true,
mv_repository: true,
remove_repository: true,
add_key: true,