Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use save_file for external repositories #1763

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 0 additions & 10 deletions app/models/repository/git.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ def save_file(tmp_file, filepath, message, user, do_parse: true)
version
end

def save_file_only(tmp_file, filepath, message, user)
commit = nil
git.add_file(user_info(user), tmp_file, filepath, message) do |commit_oid|
commit = commit_oid
end
commit_for!(commit, user)
touch
commit
end

def commit_for!(commit_oid, pusher)
instance = Commit.where(repository_id: self,
commit_oid: commit_oid).
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/ontology_versions_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
repository = @ontology.repository
user = repository.permissions.first.subject
Tempfile.create('testfile') do |f|
repository.save_file_only(f.path, @ontology.path, 'add ontology file', user)
repository.save_file(f.path, @ontology.path, 'add ontology file', user, do_parse: false)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/external_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def repository

def add_to_repository(iri, message, user, location: iri)
tmp_path = download_iri(location)
repository.save_file_only(tmp_path, determine_path(iri, :fullpath),
message, user)
repository.save_file(tmp_path, determine_path(iri, :fullpath),
message, user)
end

def determine_locid(external_iri)
Expand Down
4 changes: 1 addition & 3 deletions lib/uri_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def produce_response_body(response, write_file=nil)
if write_file
File.open(write_file.to_s, 'w') do |file|
file.flock(File::LOCK_EX)
response.read_body do |chunk|
file.write chunk
end
file.write(response.read_body)
end
write_file
else
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/files_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
tmpfile.write('unchanged')
tmpfile.close

repository.save_file_only(tmpfile, filepath, message, user)
repository.save_file(tmpfile, filepath, message, user, do_parse: false)
end

context "without validation error" do
Expand Down Expand Up @@ -159,7 +159,7 @@
tmpfile.write('unchanged')
tmpfile.close

repository.save_file_only(tmpfile, filepath, message, user)
repository.save_file(tmpfile, filepath, message, user, do_parse: false)
end

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/models/repository_directory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

let(:save_operation) do
file = Tempfile.new('tempfile').path
repository.save_file_only(file, filepath, 'message', user)
repository.save_file(file, filepath, 'message', user, do_parse: false)
end

it 'should add a commit' do
Expand Down