Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom Gerdes <thom.gerdes@gmail.com>2013-12-23 13:37:38 +0400
committerThom Gerdes <thom.gerdes@gmail.com>2013-12-26 17:54:13 +0400
commit27912f9c21c3dfb20f8d1d037f8c085281de5b0e (patch)
tree9eb3f60ab873ecaebee11d3c171f58d258f2952d /lib/api/repositories.rb
parentb27bd2b10d08e16663d6554d11e0eeef708a87d5 (diff)
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.rb22
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: