summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2016-04-05 13:46:14 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2016-04-05 13:46:14 +0000
commite1bc16cbdf179425bb54fb41caacad2c4c99fe17 (patch)
tree2b4ebed63be09b05c91f7e6cc533af0c0543b3c2
parent353365c7f2646be7ab0efff45980cd781763696d (diff)
parentaad3b6ddf88e31072602af7d1d06f64e1823673b (diff)
downloadgitlab-ce-e1bc16cbdf179425bb54fb41caacad2c4c99fe17.tar.gz
Merge branch 'reorder-language' into 'master'
Update language after doing all other operations See merge request !3533
-rw-r--r--app/services/git_push_service.rb10
-rw-r--r--spec/services/git_push_service_spec.rb18
2 files changed, 21 insertions, 7 deletions
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index c007d648dd6..36c9ee92da1 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -43,17 +43,21 @@ class GitPushService < BaseService
@push_commits = @project.repository.commits_between(params[:oldrev], params[:newrev])
process_commit_messages
end
- # Checks if the main language has changed in the project and if so
- # it updates it accordingly
- update_main_language
# Update merge requests that may be affected by this push. A new branch
# could cause the last commit of a merge request to change.
update_merge_requests
+ # Checks if the main language has changed in the project and if so
+ # it updates it accordingly
+ update_main_language
+
perform_housekeeping
end
def update_main_language
+ return unless is_default_branch?
+ return unless push_to_new_branch? || push_to_existing_branch?
+
current_language = @project.repository.main_language
unless current_language == @project.main_language
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index 8490a729e51..1047e32960e 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -159,18 +159,28 @@ describe GitPushService, services: true do
end
describe "Updates main language" do
-
context "before push" do
it { expect(project.main_language).to eq(nil) }
end
context "after push" do
before do
- @service = execute_service(project, user, @oldrev, @newrev, @ref)
+ @service = execute_service(project, user, @oldrev, @newrev, ref)
+ end
+
+ context "to master" do
+ let(:ref) { @ref }
+
+ it { expect(@service.update_main_language).to eq(true) }
+ it { expect(project.main_language).to eq("Ruby") }
end
- it { expect(@service.update_main_language).to eq(true) }
- it { expect(project.main_language).to eq("Ruby") }
+ context "to other branch" do
+ let(:ref) { 'refs/heads/feature/branch' }
+
+ it { expect(@service.update_main_language).to eq(nil) }
+ it { expect(project.main_language).to eq(nil) }
+ end
end
end