Commit 9a26e9a0d634c8bb796f0b08f6397d1e343bd4be
1 parent
541d8994
Exists in
master
and in
4 other branches
Dont init repo on every create(:repo)
Showing
7 changed files
with
18 additions
and
11 deletions
Show diff stats
app/helpers/commits_helper.rb
| ... | ... | @@ -147,10 +147,6 @@ module CommitsHelper |
| 147 | 147 | |
| 148 | 148 | protected |
| 149 | 149 | |
| 150 | - def no_commit_message | |
| 151 | - "--no commit message" | |
| 152 | - end | |
| 153 | - | |
| 154 | 150 | # Private: Returns a link to a person. If the person has a matching user and |
| 155 | 151 | # is a member of the current @project it will link to the team member page. |
| 156 | 152 | # Otherwise it will link to the person email as specified in the commit. | ... | ... |
app/models/gollum_wiki.rb
| ... | ... | @@ -90,13 +90,17 @@ class GollumWiki |
| 90 | 90 | private |
| 91 | 91 | |
| 92 | 92 | def create_repo! |
| 93 | - if gitlab_shell.add_repository(path_with_namespace) | |
| 93 | + if init_repo(path_with_namespace) | |
| 94 | 94 | Gollum::Wiki.new(path_to_repo) |
| 95 | 95 | else |
| 96 | 96 | raise CouldNotCreateWikiError |
| 97 | 97 | end |
| 98 | 98 | end |
| 99 | 99 | |
| 100 | + def init_repo(path_with_namespace) | |
| 101 | + gitlab_shell.add_repository(path_with_namespace) | |
| 102 | + end | |
| 103 | + | |
| 100 | 104 | def commit_details(action, message = nil, title = nil) |
| 101 | 105 | commit_message = message || default_message(action, title) |
| 102 | 106 | ... | ... |
lib/gitlab/git/commit.rb
spec/factories.rb
| ... | ... | @@ -86,9 +86,9 @@ FactoryGirl.define do |
| 86 | 86 | target_branch "master" # pretend bcf03b5d~3 |
| 87 | 87 | source_branch "stable" # pretend bcf03b5d |
| 88 | 88 | st_commits do |
| 89 | - [Commit.new(project.repo.commit('bcf03b5d')), | |
| 90 | - Commit.new(project.repo.commit('bcf03b5d~1')), | |
| 91 | - Commit.new(project.repo.commit('bcf03b5d~2'))] | |
| 89 | + [Commit.new(project.repository.commit('bcf03b5d')), | |
| 90 | + Commit.new(project.repository.commit('bcf03b5d~1')), | |
| 91 | + Commit.new(project.repository.commit('bcf03b5d~2'))] | |
| 92 | 92 | end |
| 93 | 93 | st_diffs do |
| 94 | 94 | project.repo.diff("bcf03b5d~3", "bcf03b5d") |
| ... | ... | @@ -120,6 +120,7 @@ FactoryGirl.define do |
| 120 | 120 | factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff] |
| 121 | 121 | |
| 122 | 122 | trait :on_commit do |
| 123 | + project factory: :project_with_code | |
| 123 | 124 | commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" |
| 124 | 125 | noteable_type "Commit" |
| 125 | 126 | end |
| ... | ... | @@ -129,6 +130,7 @@ FactoryGirl.define do |
| 129 | 130 | end |
| 130 | 131 | |
| 131 | 132 | trait :on_merge_request do |
| 133 | + project factory: :project_with_code | |
| 132 | 134 | noteable_id 1 |
| 133 | 135 | noteable_type "MergeRequest" |
| 134 | 136 | end | ... | ... |
spec/models/commit_spec.rb
spec/models/gollum_wiki_spec.rb
| ... | ... | @@ -81,7 +81,7 @@ describe GollumWiki do |
| 81 | 81 | end |
| 82 | 82 | |
| 83 | 83 | it "raises CouldNotCreateWikiError if it can't create the wiki repository" do |
| 84 | - Gitlab::Shell.any_instance.stub(:add_repository).and_return(false) | |
| 84 | + GollumWiki.any_instance.stub(:init_repo).and_return(false) | |
| 85 | 85 | expect { GollumWiki.new(project, user).wiki }.to raise_exception(GollumWiki::CouldNotCreateWikiError) |
| 86 | 86 | end |
| 87 | 87 | end | ... | ... |
spec/support/test_env.rb
| ... | ... | @@ -17,11 +17,12 @@ module TestEnv |
| 17 | 17 | repos_path = Rails.root.join('tmp', 'test-git-base-path') |
| 18 | 18 | Gitlab.config.gitlab_shell.stub(repos_path: repos_path) |
| 19 | 19 | |
| 20 | - Gitlab::Shell.any_instance.stub(:add_repository) do |path| | |
| 20 | + GollumWiki.any_instance.stub(:init_repo) do |path| | |
| 21 | 21 | create_temp_repo(File.join(repos_path, "#{path}.git")) |
| 22 | 22 | end |
| 23 | 23 | |
| 24 | 24 | Gitlab::Shell.any_instance.stub( |
| 25 | + add_repository: true, | |
| 25 | 26 | mv_repository: true, |
| 26 | 27 | remove_repository: true, |
| 27 | 28 | add_key: true, | ... | ... |