mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-15 15:46:08 +10:00
Merge branch 'minor_refactoring' into 'master'
Minor refactoring Add Repository#blob_at_branch method
This commit is contained in:
@@ -178,4 +178,14 @@ class Repository
|
||||
|
||||
Tree.new(self, sha, path)
|
||||
end
|
||||
|
||||
def blob_at_branch(branch_name, path)
|
||||
last_commit = commit(branch_name)
|
||||
|
||||
if last_commit
|
||||
blob_at(last_commit.sha, path)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,8 +24,7 @@ module Files
|
||||
return error("Your changes could not be committed, because file name contains not allowed characters")
|
||||
end
|
||||
|
||||
commit = repository.commit(ref)
|
||||
blob = repository.blob_at(commit.sha, file_path)
|
||||
blob = repository.blob_at_branch(ref, file_path)
|
||||
|
||||
if blob
|
||||
return error("Your changes could not be committed, because file with such name exists")
|
||||
|
||||
@@ -17,8 +17,7 @@ module Files
|
||||
return error("You can only create files if you are on top of a branch")
|
||||
end
|
||||
|
||||
commit = repository.commit(ref)
|
||||
blob = repository.blob_at(commit.sha, path)
|
||||
blob = repository.blob_at_branch(ref, path)
|
||||
|
||||
unless blob
|
||||
return error("You can only edit text files")
|
||||
|
||||
@@ -17,8 +17,7 @@ module Files
|
||||
return error("You can only create files if you are on top of a branch")
|
||||
end
|
||||
|
||||
commit = repository.commit(ref)
|
||||
blob = repository.blob_at(commit.sha, path)
|
||||
blob = repository.blob_at_branch(ref, path)
|
||||
|
||||
unless blob
|
||||
return error("You can only edit text files")
|
||||
|
||||
Reference in New Issue
Block a user