Commit 231b91d0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of github.com:gitlabhq/gitlabhq

parents 0f72f00c a4000f5d
......@@ -160,6 +160,7 @@ class ApplicationController < ActionController::Base
def default_headers
headers['X-Frame-Options'] = 'DENY'
headers['X-XSS-Protection'] = '1; mode=block'
headers['X-UA-Compatible'] = 'IE=edge'
end
def add_gon_variables
......
......@@ -343,9 +343,9 @@ Parameters:
```
## Raw blob content
## Raw file content
Get the raw file contents for a file.
Get the raw file contents for a file by commit sha and path.
```
GET /projects/:id/repository/blobs/:sha
......@@ -358,6 +358,20 @@ Parameters:
+ `filepath` (required) - The path the file
## Raw blob content
Get the raw file contents for a blob by blob sha.
```
GET /projects/:id/repository/raw_blobs/:sha
```
Parameters:
+ `id` (required) - The ID of a project
+ `sha` (required) - The blob sha
## Get file archive
Get a an archive of the repository
......
......@@ -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:
......
......@@ -225,6 +225,13 @@ describe API::API do
end
end
describe "GET /projects/:id/repository/raw_blobs/:sha" do
it "should get the raw file contents" do
get api("/projects/#{project.id}/repository/raw_blobs/d1aff2896d99d7acc4d9780fbb716b113c45ecf7", user)
response.status.should == 200
end
end
describe "GET /projects/:id/repository/archive/:sha" do
it "should get the archive" do
get api("/projects/#{project.id}/repository/archive", user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment