Commit fc16a228c915437e17dc040e2798c26acac8fd86

Authored by Dmitriy Zaporozhets
1 parent 31987259

Fix blobs for file services

Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/services/files/create_service.rb
@@ -24,7 +24,8 @@ module Files @@ -24,7 +24,8 @@ module Files
24 return error("Your changes could not be committed, because file name contains not allowed characters") 24 return error("Your changes could not be committed, because file name contains not allowed characters")
25 end 25 end
26 26
27 - blob = repository.blob_at(ref, file_path) 27 + commit = repository.commit(ref)
  28 + blob = repository.blob_at(commit.sha, file_path)
28 29
29 if blob 30 if blob
30 return error("Your changes could not be committed, because file with such name exists") 31 return error("Your changes could not be committed, because file with such name exists")
app/services/files/delete_service.rb
@@ -17,7 +17,8 @@ module Files @@ -17,7 +17,8 @@ module Files
17 return error("You can only create files if you are on top of a branch") 17 return error("You can only create files if you are on top of a branch")
18 end 18 end
19 19
20 - blob = repository.blob_at(ref, path) 20 + commit = repository.commit(ref)
  21 + blob = repository.blob_at(commit.sha, path)
21 22
22 unless blob 23 unless blob
23 return error("You can only edit text files") 24 return error("You can only edit text files")
app/services/files/update_service.rb
@@ -17,7 +17,8 @@ module Files @@ -17,7 +17,8 @@ module Files
17 return error("You can only create files if you are on top of a branch") 17 return error("You can only create files if you are on top of a branch")
18 end 18 end
19 19
20 - blob = repository.blob_at(ref, path) 20 + commit = repository.commit(ref)
  21 + blob = repository.blob_at(commit.sha, path)
21 22
22 unless blob 23 unless blob
23 return error("You can only edit text files") 24 return error("You can only edit text files")