diff options
author | Thom Gerdes <thom.gerdes@gmail.com> | 2013-12-23 01:37:38 -0800 |
---|---|---|
committer | Thom Gerdes <thom.gerdes@gmail.com> | 2013-12-26 08:54:13 -0500 |
commit | 27912f9c21c3dfb20f8d1d037f8c085281de5b0e (patch) | |
tree | 9eb3f60ab873ecaebee11d3c171f58d258f2952d /lib/api/repositories.rb | |
parent | b27bd2b10d08e16663d6554d11e0eeef708a87d5 (diff) | |
download | gitlab-ce-27912f9c21c3dfb20f8d1d037f8c085281de5b0e.tar.gz |
Add api support for raw blob search
See issue
http://feedback.gitlab.com/forums/176466-general/suggestions/4566001-expose-raw-object-search-via-the-gitlab-api
Diffstat (limited to 'lib/api/repositories.rb')
-rw-r--r-- | lib/api/repositories.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb index c9422fdb165..6a9dc9a39f1 100644 --- a/lib/api/repositories.rb +++ b/lib/api/repositories.rb @@ -177,6 +177,28 @@ module API present blob.data end + # Get a raw blob contents by blob sha + # + # Parameters: + # id (required) - The ID of a project + # sha (required) - The blob's sha + # Example Request: + # GET /projects/:id/repository/raw_blobs/:sha + get ":id/repository/raw_blobs/:sha" do + ref = params[:sha] + + repo = user_project.repository + + blob = Gitlab::Git::Blob.raw(repo, ref) + + not_found! "Blob" unless blob + + env['api.format'] = :txt + + content_type blob.mime_type + present blob.data + end + # Get a an archive of the repository # # Parameters: |