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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
32d7332d
Commit
32d7332d
authored
Nov 19, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API: delete file from repository
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
bd20ec1a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
3 deletions
+43
-3
doc/api/repositories.md
doc/api/repositories.md
+12
-0
lib/api/files.rb
lib/api/files.rb
+31
-3
No files found.
doc/api/repositories.md
View file @
32d7332d
...
...
@@ -397,3 +397,15 @@ Parameters:
+
`branch_name`
(required) - The name of branch
+
`content`
(required) - New file content
+
`commit_message`
(required) - Commit message
## Delete existing file in repository
```
DELETE /projects/:id/repository/files
```
Parameters:
+
`file_path`
(required) - Full path to file. Ex. lib/class.rb
+
`branch_name`
(required) - The name of branch
+
`commit_message`
(required) - Commit message
lib/api/files.rb
View file @
32d7332d
...
...
@@ -40,8 +40,7 @@ module API
# Update existing file in repository
#
# Parameters:
# file_name (required) - The name of new file. Ex. class.rb
# file_path (optional) - The path to new file. Ex. lib/
# file_path (optional) - The path to file. Ex. lib/class.rb
# branch_name (required) - The name of branch
# content (required) - File content
# commit_message (required) - Commit message
...
...
@@ -67,7 +66,36 @@ module API
render_api_error!
(
result
[
:error
],
400
)
end
end
# Delete existing file in repository
#
# Parameters:
# file_path (optional) - The path to file. Ex. lib/class.rb
# branch_name (required) - The name of branch
# content (required) - File content
# commit_message (required) - Commit message
#
# Example Request:
# DELETE /projects/:id/repository/files
#
delete
":id/repository/files"
do
required_attributes!
[
:file_path
,
:branch_name
,
:commit_message
]
attrs
=
attributes_for_keys
[
:file_path
,
:branch_name
,
:commit_message
]
branch_name
=
attrs
.
delete
(
:branch_name
)
file_path
=
attrs
.
delete
(
:file_path
)
result
=
::
Files
::
DeleteContext
.
new
(
user_project
,
current_user
,
attrs
,
branch_name
,
file_path
).
execute
if
result
[
:status
]
==
:success
status
(
200
)
{
file_path:
file_path
,
branch_name:
branch_name
}
else
render_api_error!
(
result
[
:error
],
400
)
end
end
end
end
end
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