Commit e1bc16cb authored by Yorick Peterse's avatar Yorick Peterse

Merge branch 'reorder-language' into 'master'

Update language after doing all other operations

See merge request !3533
parents 353365c7 aad3b6dd
...@@ -43,17 +43,21 @@ class GitPushService < BaseService ...@@ -43,17 +43,21 @@ class GitPushService < BaseService
@push_commits = @project.repository.commits_between(params[:oldrev], params[:newrev]) @push_commits = @project.repository.commits_between(params[:oldrev], params[:newrev])
process_commit_messages process_commit_messages
end 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 # Update merge requests that may be affected by this push. A new branch
# could cause the last commit of a merge request to change. # could cause the last commit of a merge request to change.
update_merge_requests 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 perform_housekeeping
end end
def update_main_language 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 current_language = @project.repository.main_language
unless current_language == @project.main_language unless current_language == @project.main_language
......
...@@ -159,19 +159,29 @@ describe GitPushService, services: true do ...@@ -159,19 +159,29 @@ describe GitPushService, services: true do
end end
describe "Updates main language" do describe "Updates main language" do
context "before push" do context "before push" do
it { expect(project.main_language).to eq(nil) } it { expect(project.main_language).to eq(nil) }
end end
context "after push" do context "after push" do
before do before do
@service = execute_service(project, user, @oldrev, @newrev, @ref) @service = execute_service(project, user, @oldrev, @newrev, ref)
end end
context "to master" do
let(:ref) { @ref }
it { expect(@service.update_main_language).to eq(true) } it { expect(@service.update_main_language).to eq(true) }
it { expect(project.main_language).to eq("Ruby") } it { expect(project.main_language).to eq("Ruby") }
end end
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 end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment