Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
eb63e9addad1
Unverified
Commit
55572c4e
authored
Feb 05, 2014
by
Dmitriy Zaporozhets
Browse files
Repository#blob_at_branch
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
4f727e0258f4
Changes
4
Hide whitespace changes
Inline
Side-by-side
app/models/repository.rb
View file @
eb63e9ad
...
...
@@ -178,4 +178,14 @@ def tree(sha = :head, path = nil)
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
app/services/files/create_service.rb
View file @
eb63e9ad
...
...
@@ -24,8 +24,7 @@ def execute
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"
)
...
...
app/services/files/delete_service.rb
View file @
eb63e9ad
...
...
@@ -17,8 +17,7 @@ def execute
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"
)
...
...
app/services/files/update_service.rb
View file @
eb63e9ad
...
...
@@ -17,8 +17,7 @@ def execute
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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment