Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
55572c4e
Commit
55572c4e
authored
Feb 05, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Repository#blob_at_branch
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
d701d586
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
6 deletions
+13
-6
app/models/repository.rb
app/models/repository.rb
+10
-0
app/services/files/create_service.rb
app/services/files/create_service.rb
+1
-2
app/services/files/delete_service.rb
app/services/files/delete_service.rb
+1
-2
app/services/files/update_service.rb
app/services/files/update_service.rb
+1
-2
No files found.
app/models/repository.rb
View file @
55572c4e
...
...
@@ -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
app/services/files/create_service.rb
View file @
55572c4e
...
...
@@ -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"
)
...
...
app/services/files/delete_service.rb
View file @
55572c4e
...
...
@@ -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"
)
...
...
app/services/files/update_service.rb
View file @
55572c4e
...
...
@@ -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"
)
...
...
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