Commit faa2e2df authored by Douwe Maan's avatar Douwe Maan

Rename commit_file, commit_dir and remove_file and update specs

parent 0625af3b
...@@ -747,7 +747,7 @@ class Repository ...@@ -747,7 +747,7 @@ class Repository
end end
# rubocop:disable Metrics/ParameterLists # rubocop:disable Metrics/ParameterLists
def commit_dir( def create_dir(
user, path, user, path,
message:, branch_name:, message:, branch_name:,
author_email: nil, author_name: nil, author_email: nil, author_name: nil,
...@@ -778,14 +778,12 @@ class Repository ...@@ -778,14 +778,12 @@ class Repository
# rubocop:enable Metrics/ParameterLists # rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists # rubocop:disable Metrics/ParameterLists
def commit_file( def create_file(
user, path, content, user, path, content,
message:, branch_name:, update: true, message:, branch_name:,
author_email: nil, author_name: nil, author_email: nil, author_name: nil,
start_branch_name: nil, start_project: project) start_branch_name: nil, start_project: project)
action = update ? :update : :create
multi_action( multi_action(
user: user, user: user,
message: message, message: message,
...@@ -794,7 +792,7 @@ class Repository ...@@ -794,7 +792,7 @@ class Repository
author_name: author_name, author_name: author_name,
start_branch_name: start_branch_name, start_branch_name: start_branch_name,
start_project: start_project, start_project: start_project,
actions: [{ action: action, actions: [{ action: :create,
file_path: path, file_path: path,
content: content }]) content: content }])
end end
...@@ -803,7 +801,7 @@ class Repository ...@@ -803,7 +801,7 @@ class Repository
# rubocop:disable Metrics/ParameterLists # rubocop:disable Metrics/ParameterLists
def update_file( def update_file(
user, path, content, user, path, content,
message:, branch_name:, previous_path:, message:, branch_name:, previous_path: nil,
author_email: nil, author_name: nil, author_email: nil, author_name: nil,
start_branch_name: nil, start_project: project) start_branch_name: nil, start_project: project)
action = if previous_path && previous_path != path action = if previous_path && previous_path != path
...@@ -828,7 +826,7 @@ class Repository ...@@ -828,7 +826,7 @@ class Repository
# rubocop:enable Metrics/ParameterLists # rubocop:enable Metrics/ParameterLists
# rubocop:disable Metrics/ParameterLists # rubocop:disable Metrics/ParameterLists
def remove_file( def delete_file(
user, path, user, path,
message:, branch_name:, message:, branch_name:,
author_email: nil, author_name: nil, author_email: nil, author_name: nil,
......
module Files module Files
class CreateDirService < Files::BaseService class CreateDirService < Files::BaseService
def commit def commit
repository.commit_dir( repository.create_dir(
current_user, current_user,
@file_path, @file_path,
message: @commit_message, message: @commit_message,
......
module Files module Files
class CreateService < Files::BaseService class CreateService < Files::BaseService
def commit def commit
repository.commit_file( repository.create_file(
current_user, current_user,
@file_path, @file_path,
@file_content, @file_content,
message: @commit_message, message: @commit_message,
branch_name: @target_branch, branch_name: @target_branch,
update: false,
author_email: @author_email, author_email: @author_email,
author_name: @author_name, author_name: @author_name,
start_project: @start_project, start_project: @start_project,
......
module Files module Files
class DestroyService < Files::BaseService class DestroyService < Files::BaseService
def commit def commit
repository.remove_file( repository.delete_file(
current_user, current_user,
@file_path, @file_path,
message: @commit_message, message: @commit_message,
......
...@@ -155,7 +155,7 @@ class Gitlab::Seeder::CycleAnalytics ...@@ -155,7 +155,7 @@ class Gitlab::Seeder::CycleAnalytics
issue.project.repository.add_branch(@user, branch_name, 'master') issue.project.repository.add_branch(@user, branch_name, 'master')
commit_sha = issue.project.repository.commit_file(@user, filename, "content", options, message: "Commit for ##{issue.iid}", branch_name: branch_name) commit_sha = issue.project.repository.create_file(@user, filename, "content", options, message: "Commit for ##{issue.iid}", branch_name: branch_name)
issue.project.repository.commit(commit_sha) issue.project.repository.commit(commit_sha)
GitPushService.new(issue.project, GitPushService.new(issue.project,
......
...@@ -14,8 +14,8 @@ describe Projects::TemplatesController do ...@@ -14,8 +14,8 @@ describe Projects::TemplatesController do
before do before do
project.add_user(user, Gitlab::Access::MASTER) project.add_user(user, Gitlab::Access::MASTER)
project.repository.commit_file(user, file_path_1, 'something valid', project.repository.create_file(user, file_path_1, 'something valid',
message: 'test 3', branch_name: 'master', update: false) message: 'test 3', branch_name: 'master')
end end
describe '#show' do describe '#show' do
......
...@@ -138,27 +138,24 @@ FactoryGirl.define do ...@@ -138,27 +138,24 @@ FactoryGirl.define do
project.add_user(args[:user], args[:access]) project.add_user(args[:user], args[:access])
project.repository.commit_file( project.repository.create_file(
args[:user], args[:user],
".gitlab/#{args[:path]}/bug.md", ".gitlab/#{args[:path]}/bug.md",
'something valid', 'something valid',
message: 'test 3', message: 'test 3',
branch_name: 'master', branch_name: 'master')
update: false) project.repository.create_file(
project.repository.commit_file(
args[:user], args[:user],
".gitlab/#{args[:path]}/template_test.md", ".gitlab/#{args[:path]}/template_test.md",
'template_test', 'template_test',
message: 'test 1', message: 'test 1',
branch_name: 'master', branch_name: 'master')
update: false) project.repository.create_file(
project.repository.commit_file(
args[:user], args[:user],
".gitlab/#{args[:path]}/feature_proposal.md", ".gitlab/#{args[:path]}/feature_proposal.md",
'feature_proposal', 'feature_proposal',
message: 'test 2', message: 'test 2',
branch_name: 'master', branch_name: 'master')
update: false)
end end
end end
end end
......
...@@ -6,7 +6,7 @@ feature 'project owner creates a license file', feature: true, js: true do ...@@ -6,7 +6,7 @@ feature 'project owner creates a license file', feature: true, js: true do
let(:project_master) { create(:user) } let(:project_master) { create(:user) }
let(:project) { create(:project) } let(:project) { create(:project) }
background do background do
project.repository.remove_file(project_master, 'LICENSE', project.repository.delete_file(project_master, 'LICENSE',
message: 'Remove LICENSE', branch_name: 'master') message: 'Remove LICENSE', branch_name: 'master')
project.team << [project_master, :master] project.team << [project_master, :master]
login_as(project_master) login_as(project_master)
......
...@@ -18,20 +18,18 @@ feature 'issuable templates', feature: true, js: true do ...@@ -18,20 +18,18 @@ feature 'issuable templates', feature: true, js: true do
let(:description_addition) { ' appending to description' } let(:description_addition) { ' appending to description' }
background do background do
project.repository.commit_file( project.repository.create_file(
user, user,
'.gitlab/issue_templates/bug.md', '.gitlab/issue_templates/bug.md',
template_content, template_content,
message: 'added issue template', message: 'added issue template',
branch_name: 'master', branch_name: 'master')
update: false) project.repository.create_file(
project.repository.commit_file(
user, user,
'.gitlab/issue_templates/test.md', '.gitlab/issue_templates/test.md',
longtemplate_content, longtemplate_content,
message: 'added issue template', message: 'added issue template',
branch_name: 'master', branch_name: 'master')
update: false)
visit edit_namespace_project_issue_path project.namespace, project, issue visit edit_namespace_project_issue_path project.namespace, project, issue
fill_in :'issue[title]', with: 'test issue title' fill_in :'issue[title]', with: 'test issue title'
end end
...@@ -79,13 +77,12 @@ feature 'issuable templates', feature: true, js: true do ...@@ -79,13 +77,12 @@ feature 'issuable templates', feature: true, js: true do
let(:issue) { create(:issue, author: user, assignee: user, project: project) } let(:issue) { create(:issue, author: user, assignee: user, project: project) }
background do background do
project.repository.commit_file( project.repository.create_file(
user, user,
'.gitlab/issue_templates/bug.md', '.gitlab/issue_templates/bug.md',
template_content, template_content,
message: 'added issue template', message: 'added issue template',
branch_name: 'master', branch_name: 'master')
update: false)
visit edit_namespace_project_issue_path project.namespace, project, issue visit edit_namespace_project_issue_path project.namespace, project, issue
fill_in :'issue[title]', with: 'test issue title' fill_in :'issue[title]', with: 'test issue title'
fill_in :'issue[description]', with: prior_description fill_in :'issue[description]', with: prior_description
...@@ -104,13 +101,12 @@ feature 'issuable templates', feature: true, js: true do ...@@ -104,13 +101,12 @@ feature 'issuable templates', feature: true, js: true do
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project) } let(:merge_request) { create(:merge_request, :with_diffs, source_project: project) }
background do background do
project.repository.commit_file( project.repository.create_file(
user, user,
'.gitlab/merge_request_templates/feature-proposal.md', '.gitlab/merge_request_templates/feature-proposal.md',
template_content, template_content,
message: 'added merge request template', message: 'added merge request template',
branch_name: 'master', branch_name: 'master')
update: false)
visit edit_namespace_project_merge_request_path project.namespace, project, merge_request visit edit_namespace_project_merge_request_path project.namespace, project, merge_request
fill_in :'merge_request[title]', with: 'test merge request title' fill_in :'merge_request[title]', with: 'test merge request title'
end end
...@@ -135,13 +131,12 @@ feature 'issuable templates', feature: true, js: true do ...@@ -135,13 +131,12 @@ feature 'issuable templates', feature: true, js: true do
fork_project.team << [fork_user, :master] fork_project.team << [fork_user, :master]
create(:forked_project_link, forked_to_project: fork_project, forked_from_project: project) create(:forked_project_link, forked_to_project: fork_project, forked_from_project: project)
login_as fork_user login_as fork_user
project.repository.commit_file( project.repository.create_file(
fork_user, fork_user,
'.gitlab/merge_request_templates/feature-proposal.md', '.gitlab/merge_request_templates/feature-proposal.md',
template_content, template_content,
message: 'added merge request template', message: 'added merge request template',
branch_name: 'master', branch_name: 'master')
update: false)
visit edit_namespace_project_merge_request_path project.namespace, project, merge_request visit edit_namespace_project_merge_request_path project.namespace, project, merge_request
fill_in :'merge_request[title]', with: 'test merge request title' fill_in :'merge_request[title]', with: 'test merge request title'
end end
......
...@@ -209,13 +209,12 @@ describe Gitlab::GitAccess, lib: true do ...@@ -209,13 +209,12 @@ describe Gitlab::GitAccess, lib: true do
stub_git_hooks stub_git_hooks
project.repository.add_branch(user, unprotected_branch, 'feature') project.repository.add_branch(user, unprotected_branch, 'feature')
target_branch = project.repository.lookup('feature') target_branch = project.repository.lookup('feature')
source_branch = project.repository.commit_file( source_branch = project.repository.create_file(
user, user,
FFaker::InternetSE.login_user_name, FFaker::InternetSE.login_user_name,
FFaker::HipsterIpsum.paragraph, FFaker::HipsterIpsum.paragraph,
message: FFaker::HipsterIpsum.sentence, message: FFaker::HipsterIpsum.sentence,
branch_name: unprotected_branch, branch_name: unprotected_branch)
update: false)
rugged = project.repository.rugged rugged = project.repository.rugged
author = { email: "email@example.com", time: Time.now, name: "Example Git User" } author = { email: "email@example.com", time: Time.now, name: "Example Git User" }
......
...@@ -21,13 +21,12 @@ describe 'CycleAnalytics#production', feature: true do ...@@ -21,13 +21,12 @@ describe 'CycleAnalytics#production', feature: true do
["production deploy happens after merge request is merged (along with other changes)", ["production deploy happens after merge request is merged (along with other changes)",
lambda do |context, data| lambda do |context, data|
# Make other changes on master # Make other changes on master
sha = context.project.repository.commit_file( sha = context.project.repository.create_file(
context.user, context.user,
context.random_git_name, context.random_git_name,
'content', 'content',
message: 'commit message', message: 'commit message',
branch_name: 'master', branch_name: 'master')
update: false)
context.project.repository.commit(sha) context.project.repository.commit(sha)
context.deploy_master context.deploy_master
......
...@@ -26,13 +26,12 @@ describe 'CycleAnalytics#staging', feature: true do ...@@ -26,13 +26,12 @@ describe 'CycleAnalytics#staging', feature: true do
["production deploy happens after merge request is merged (along with other changes)", ["production deploy happens after merge request is merged (along with other changes)",
lambda do |context, data| lambda do |context, data|
# Make other changes on master # Make other changes on master
sha = context.project.repository.commit_file( sha = context.project.repository.create_file(
context.user, context.user,
context.random_git_name, context.random_git_name,
'content', 'content',
message: 'commit message', message: 'commit message',
branch_name: 'master', branch_name: 'master')
update: false)
context.project.repository.commit(sha) context.project.repository.commit(sha)
context.deploy_master context.deploy_master
......
...@@ -1765,7 +1765,7 @@ describe Project, models: true do ...@@ -1765,7 +1765,7 @@ describe Project, models: true do
end end
before do before do
project.repository.commit_file(User.last, '.gitlab/route-map.yml', route_map, message: 'Add .gitlab/route-map.yml', branch_name: 'master', update: false) project.repository.create_file(User.last, '.gitlab/route-map.yml', route_map, message: 'Add .gitlab/route-map.yml', branch_name: 'master')
end end
context 'when there is a .gitlab/route-map.yml at the commit' do context 'when there is a .gitlab/route-map.yml at the commit' do
......
...@@ -294,7 +294,7 @@ describe Repository, models: true do ...@@ -294,7 +294,7 @@ describe Repository, models: true do
describe "#commit_dir" do describe "#commit_dir" do
it "commits a change that creates a new directory" do it "commits a change that creates a new directory" do
expect do expect do
repository.commit_dir(user, 'newdir', repository.create_dir(user, 'newdir',
message: 'Create newdir', branch_name: 'master') message: 'Create newdir', branch_name: 'master')
end.to change { repository.commits('master').count }.by(1) end.to change { repository.commits('master').count }.by(1)
...@@ -307,7 +307,7 @@ describe Repository, models: true do ...@@ -307,7 +307,7 @@ describe Repository, models: true do
it "creates a fork and commit to the forked project" do it "creates a fork and commit to the forked project" do
expect do expect do
repository.commit_dir(user, 'newdir', repository.create_dir(user, 'newdir',
message: 'Create newdir', branch_name: 'patch', message: 'Create newdir', branch_name: 'patch',
start_branch_name: 'master', start_project: forked_project) start_branch_name: 'master', start_project: forked_project)
end.to change { repository.commits('master').count }.by(0) end.to change { repository.commits('master').count }.by(0)
...@@ -323,7 +323,7 @@ describe Repository, models: true do ...@@ -323,7 +323,7 @@ describe Repository, models: true do
context "when an author is specified" do context "when an author is specified" do
it "uses the given email/name to set the commit's author" do it "uses the given email/name to set the commit's author" do
expect do expect do
repository.commit_dir(user, 'newdir', repository.create_dir(user, 'newdir',
message: 'Add newdir', message: 'Add newdir',
branch_name: 'master', branch_name: 'master',
author_email: author_email, author_name: author_name) author_email: author_email, author_name: author_name)
...@@ -337,25 +337,23 @@ describe Repository, models: true do ...@@ -337,25 +337,23 @@ describe Repository, models: true do
end end
end end
describe "#commit_file" do describe "#create_file" do
it 'commits change to a file successfully' do it 'commits new file successfully' do
expect do expect do
repository.commit_file(user, 'CHANGELOG', 'Changelog!', repository.create_file(user, 'NEWCHANGELOG', 'Changelog!',
message: 'Updates file content', message: 'Create changelog',
branch_name: 'master', branch_name: 'master')
update: true)
end.to change { repository.commits('master').count }.by(1) end.to change { repository.commits('master').count }.by(1)
blob = repository.blob_at('master', 'CHANGELOG') blob = repository.blob_at('master', 'NEWCHANGELOG')
expect(blob.data).to eq('Changelog!') expect(blob.data).to eq('Changelog!')
end end
it 'respects the autocrlf setting' do it 'respects the autocrlf setting' do
repository.commit_file(user, 'hello.txt', "Hello,\r\nWorld", repository.create_file(user, 'hello.txt', "Hello,\r\nWorld",
message: 'Add hello world', message: 'Add hello world',
branch_name: 'master', branch_name: 'master')
update: false)
blob = repository.blob_at('master', 'hello.txt') blob = repository.blob_at('master', 'hello.txt')
...@@ -365,10 +363,9 @@ describe Repository, models: true do ...@@ -365,10 +363,9 @@ describe Repository, models: true do
context "when an author is specified" do context "when an author is specified" do
it "uses the given email/name to set the commit's author" do it "uses the given email/name to set the commit's author" do
expect do expect do
repository.commit_file(user, 'README', 'README!', repository.create_file(user, 'NEWREADME', 'README!',
message: 'Add README', message: 'Add README',
branch_name: 'master', branch_name: 'master',
update: true,
author_email: author_email, author_email: author_email,
author_name: author_name) author_name: author_name)
end.to change { repository.commits('master').count }.by(1) end.to change { repository.commits('master').count }.by(1)
...@@ -382,6 +379,18 @@ describe Repository, models: true do ...@@ -382,6 +379,18 @@ describe Repository, models: true do
end end
describe "#update_file" do describe "#update_file" do
it 'updates file successfully' do
expect do
repository.update_file(user, 'CHANGELOG', 'Changelog!',
message: 'Update changelog',
branch_name: 'master')
end.to change { repository.commits('master').count }.by(1)
blob = repository.blob_at('master', 'CHANGELOG')
expect(blob.data).to eq('Changelog!')
end
it 'updates filename successfully' do it 'updates filename successfully' do
expect do expect do
repository.update_file(user, 'NEWLICENSE', 'Copyright!', repository.update_file(user, 'NEWLICENSE', 'Copyright!',
...@@ -398,8 +407,6 @@ describe Repository, models: true do ...@@ -398,8 +407,6 @@ describe Repository, models: true do
context "when an author is specified" do context "when an author is specified" do
it "uses the given email/name to set the commit's author" do it "uses the given email/name to set the commit's author" do
repository.commit_file(user, 'README', 'README!',
message: 'Add README', branch_name: 'master', update: true)
expect do expect do
repository.update_file(user, 'README', 'Updated README!', repository.update_file(user, 'README', 'Updated README!',
...@@ -420,11 +427,8 @@ describe Repository, models: true do ...@@ -420,11 +427,8 @@ describe Repository, models: true do
describe "#remove_file" do describe "#remove_file" do
it 'removes file successfully' do it 'removes file successfully' do
repository.commit_file(user, 'README', 'README!',
message: 'Add README', branch_name: 'master', update: true)
expect do expect do
repository.remove_file(user, 'README', repository.delete_file(user, 'README',
message: 'Remove README', branch_name: 'master') message: 'Remove README', branch_name: 'master')
end.to change { repository.commits('master').count }.by(1) end.to change { repository.commits('master').count }.by(1)
...@@ -433,11 +437,8 @@ describe Repository, models: true do ...@@ -433,11 +437,8 @@ describe Repository, models: true do
context "when an author is specified" do context "when an author is specified" do
it "uses the given email/name to set the commit's author" do it "uses the given email/name to set the commit's author" do
repository.commit_file(user, 'README', 'README!',
message: 'Add README', branch_name: 'master', update: true)
expect do expect do
repository.remove_file(user, 'README', repository.delete_file(user, 'README',
message: 'Remove README', branch_name: 'master', message: 'Remove README', branch_name: 'master',
author_email: author_email, author_name: author_name) author_email: author_email, author_name: author_name)
end.to change { repository.commits('master').count }.by(1) end.to change { repository.commits('master').count }.by(1)
...@@ -587,14 +588,14 @@ describe Repository, models: true do ...@@ -587,14 +588,14 @@ describe Repository, models: true do
describe "#license_blob", caching: true do describe "#license_blob", caching: true do
before do before do
repository.remove_file( repository.delete_file(
user, 'LICENSE', message: 'Remove LICENSE', branch_name: 'master') user, 'LICENSE', message: 'Remove LICENSE', branch_name: 'master')
end end
it 'handles when HEAD points to non-existent ref' do it 'handles when HEAD points to non-existent ref' do
repository.commit_file( repository.create_file(
user, 'LICENSE', 'Copyright!', user, 'LICENSE', 'Copyright!',
message: 'Add LICENSE', branch_name: 'master', update: false) message: 'Add LICENSE', branch_name: 'master')
allow(repository).to receive(:file_on_head). allow(repository).to receive(:file_on_head).
and_raise(Rugged::ReferenceError) and_raise(Rugged::ReferenceError)
...@@ -603,27 +604,27 @@ describe Repository, models: true do ...@@ -603,27 +604,27 @@ describe Repository, models: true do
end end
it 'looks in the root_ref only' do it 'looks in the root_ref only' do
repository.remove_file(user, 'LICENSE', repository.delete_file(user, 'LICENSE',
message: 'Remove LICENSE', branch_name: 'markdown') message: 'Remove LICENSE', branch_name: 'markdown')
repository.commit_file(user, 'LICENSE', repository.create_file(user, 'LICENSE',
Licensee::License.new('mit').content, Licensee::License.new('mit').content,
message: 'Add LICENSE', branch_name: 'markdown', update: false) message: 'Add LICENSE', branch_name: 'markdown')
expect(repository.license_blob).to be_nil expect(repository.license_blob).to be_nil
end end
it 'detects license file with no recognizable open-source license content' do it 'detects license file with no recognizable open-source license content' do
repository.commit_file(user, 'LICENSE', 'Copyright!', repository.create_file(user, 'LICENSE', 'Copyright!',
message: 'Add LICENSE', branch_name: 'master', update: false) message: 'Add LICENSE', branch_name: 'master')
expect(repository.license_blob.name).to eq('LICENSE') expect(repository.license_blob.name).to eq('LICENSE')
end end
%w[LICENSE LICENCE LiCensE LICENSE.md LICENSE.foo COPYING COPYING.md].each do |filename| %w[LICENSE LICENCE LiCensE LICENSE.md LICENSE.foo COPYING COPYING.md].each do |filename|
it "detects '#{filename}'" do it "detects '#{filename}'" do
repository.commit_file(user, filename, repository.create_file(user, filename,
Licensee::License.new('mit').content, Licensee::License.new('mit').content,
message: "Add #{filename}", branch_name: 'master', update: false) message: "Add #{filename}", branch_name: 'master')
expect(repository.license_blob.name).to eq(filename) expect(repository.license_blob.name).to eq(filename)
end end
...@@ -632,7 +633,7 @@ describe Repository, models: true do ...@@ -632,7 +633,7 @@ describe Repository, models: true do
describe '#license_key', caching: true do describe '#license_key', caching: true do
before do before do
repository.remove_file(user, 'LICENSE', repository.delete_file(user, 'LICENSE',
message: 'Remove LICENSE', branch_name: 'master') message: 'Remove LICENSE', branch_name: 'master')
end end
...@@ -647,16 +648,16 @@ describe Repository, models: true do ...@@ -647,16 +648,16 @@ describe Repository, models: true do
end end
it 'detects license file with no recognizable open-source license content' do it 'detects license file with no recognizable open-source license content' do
repository.commit_file(user, 'LICENSE', 'Copyright!', repository.create_file(user, 'LICENSE', 'Copyright!',
message: 'Add LICENSE', branch_name: 'master', update: false) message: 'Add LICENSE', branch_name: 'master')
expect(repository.license_key).to be_nil expect(repository.license_key).to be_nil
end end
it 'returns the license key' do it 'returns the license key' do
repository.commit_file(user, 'LICENSE', repository.create_file(user, 'LICENSE',
Licensee::License.new('mit').content, Licensee::License.new('mit').content,
message: 'Add LICENSE', branch_name: 'master', update: false) message: 'Add LICENSE', branch_name: 'master')
expect(repository.license_key).to eq('mit') expect(repository.license_key).to eq('mit')
end end
...@@ -913,10 +914,9 @@ describe Repository, models: true do ...@@ -913,10 +914,9 @@ describe Repository, models: true do
expect(empty_repository).to receive(:expire_emptiness_caches) expect(empty_repository).to receive(:expire_emptiness_caches)
expect(empty_repository).to receive(:expire_branches_cache) expect(empty_repository).to receive(:expire_branches_cache)
empty_repository.commit_file(user, 'CHANGELOG', 'Changelog!', empty_repository.create_file(user, 'CHANGELOG', 'Changelog!',
message: 'Updates file content', message: 'Updates file content',
branch_name: 'master', branch_name: 'master')
update: false)
end end
end end
end end
...@@ -1796,7 +1796,7 @@ describe Repository, models: true do ...@@ -1796,7 +1796,7 @@ describe Repository, models: true do
describe '#gitlab_ci_yml_for' do describe '#gitlab_ci_yml_for' do
before do before do
repository.commit_file(User.last, '.gitlab-ci.yml', 'CONTENT', message: 'Add .gitlab-ci.yml', branch_name: 'master', update: false) repository.create_file(User.last, '.gitlab-ci.yml', 'CONTENT', message: 'Add .gitlab-ci.yml', branch_name: 'master')
end end
context 'when there is a .gitlab-ci.yml at the commit' do context 'when there is a .gitlab-ci.yml at the commit' do
...@@ -1814,7 +1814,7 @@ describe Repository, models: true do ...@@ -1814,7 +1814,7 @@ describe Repository, models: true do
describe '#route_map_for' do describe '#route_map_for' do
before do before do
repository.commit_file(User.last, '.gitlab/route-map.yml', 'CONTENT', message: 'Add .gitlab/route-map.yml', branch_name: 'master', update: false) repository.create_file(User.last, '.gitlab/route-map.yml', 'CONTENT', message: 'Add .gitlab/route-map.yml', branch_name: 'master')
end end
context 'when there is a .gitlab/route-map.yml at the commit' do context 'when there is a .gitlab/route-map.yml at the commit' do
......
...@@ -66,13 +66,12 @@ describe MergeRequests::ResolveService do ...@@ -66,13 +66,12 @@ describe MergeRequests::ResolveService do
context 'when the source project is a fork and does not contain the HEAD of the target branch' do context 'when the source project is a fork and does not contain the HEAD of the target branch' do
let!(:target_head) do let!(:target_head) do
project.repository.commit_file( project.repository.create_file(
user, user,
'new-file-in-target', 'new-file-in-target',
'', '',
message: 'Add new file in target', message: 'Add new file in target',
branch_name: 'conflict-start', branch_name: 'conflict-start')
update: false)
end end
before do before do
......
...@@ -9,7 +9,7 @@ module CycleAnalyticsHelpers ...@@ -9,7 +9,7 @@ module CycleAnalyticsHelpers
commit_shas = Array.new(count) do |index| commit_shas = Array.new(count) do |index|
filename = random_git_name filename = random_git_name
commit_sha = project.repository.commit_file(user, filename, "content", message: message, branch_name: branch_name) commit_sha = project.repository.create_file(user, filename, "content", message: message, branch_name: branch_name)
project.repository.commit(commit_sha) project.repository.commit(commit_sha)
commit_sha commit_sha
...@@ -28,13 +28,12 @@ module CycleAnalyticsHelpers ...@@ -28,13 +28,12 @@ module CycleAnalyticsHelpers
project.repository.add_branch(user, source_branch, 'master') project.repository.add_branch(user, source_branch, 'master')
end end
sha = project.repository.commit_file( sha = project.repository.create_file(
user, user,
random_git_name, random_git_name,
'content', 'content',
message: 'commit message', message: 'commit message',
branch_name: source_branch, branch_name: source_branch)
update: false)
project.repository.commit(sha) project.repository.commit(sha)
opts = { opts = {
......
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