Commit aad3b6dd authored by Kamil Trzcinski's avatar Kamil Trzcinski

Update language only on HEAD of the repository

parent b8d1545b
...@@ -55,6 +55,9 @@ class GitPushService < BaseService ...@@ -55,6 +55,9 @@ class GitPushService < BaseService
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,18 +159,28 @@ describe GitPushService, services: true do ...@@ -159,18 +159,28 @@ 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
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 end
it { expect(@service.update_main_language).to eq(true) } context "to other branch" do
it { expect(project.main_language).to eq("Ruby") } 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 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