Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
e9514c50
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e9514c50
编写于
1月 27, 2015
作者:
D
Dmitriy Zaporozhets
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:gitlabhq/gitlabhq
上级
6d034e5f
7155507a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
46 addition
and
9 deletion
+46
-9
app/assets/javascripts/project_show.js.coffee
app/assets/javascripts/project_show.js.coffee
+1
-1
lib/api/repositories.rb
lib/api/repositories.rb
+29
-8
spec/requests/api/repositories_spec.rb
spec/requests/api/repositories_spec.rb
+16
-0
未找到文件。
app/assets/javascripts/project_show.js.coffee
浏览文件 @
e9514c50
...
...
@@ -6,7 +6,7 @@ class @ProjectShow
new
Flash
(
'Star toggle failed. Try again later.'
,
'alert'
)
$
(
"a[data-toggle='tab']"
).
on
"shown.bs.tab"
,
(
e
)
->
$
.
cookie
"default_view"
,
$
(
e
.
target
).
attr
(
"href"
)
$
.
cookie
"default_view"
,
$
(
e
.
target
).
attr
(
"href"
)
,
{
expires
:
30
}
defaultView
=
$
.
cookie
(
"default_view"
)
if
defaultView
...
...
lib/api/repositories.rb
浏览文件 @
e9514c50
...
...
@@ -58,11 +58,13 @@ module API
# ref_name (optional) - The name of a repository branch or tag, if not given the default branch is used
# Example Request:
# GET /projects/:id/repository/tree
get
":id/repository/tree"
do
get
':id/repository/tree'
do
ref
=
params
[
:ref_name
]
||
user_project
.
try
(
:default_branch
)
||
'master'
path
=
params
[
:path
]
||
nil
commit
=
user_project
.
repository
.
commit
(
ref
)
not_found!
(
'Tree'
)
unless
commit
tree
=
user_project
.
repository
.
tree
(
commit
.
id
,
path
)
present
tree
.
sorted_entries
,
with:
Entities
::
RepoTreeObject
...
...
@@ -100,14 +102,18 @@ module API
# sha (required) - The blob's sha
# Example Request:
# GET /projects/:id/repository/raw_blobs/:sha
get
":id/repository/raw_blobs/:sha"
do
get
':id/repository/raw_blobs/:sha'
do
ref
=
params
[
:sha
]
repo
=
user_project
.
repository
blob
=
Gitlab
::
Git
::
Blob
.
raw
(
repo
,
ref
)
begin
blob
=
Gitlab
::
Git
::
Blob
.
raw
(
repo
,
ref
)
rescue
not_found!
'Blob'
end
not_found!
"Blob"
unless
blob
not_found!
'Blob'
unless
blob
env
[
'api.format'
]
=
:txt
...
...
@@ -122,13 +128,23 @@ module API
# sha (optional) - the commit sha to download defaults to the tip of the default branch
# Example Request:
# GET /projects/:id/repository/archive
get
":id/repository/archive"
,
requirements:
{
format:
Gitlab
::
Regex
.
archive_formats_regex
}
do
get
':id/repository/archive'
,
requirements:
{
format:
Gitlab
::
Regex
.
archive_formats_regex
}
do
authorize!
:download_code
,
user_project
file_path
=
ArchiveRepositoryService
.
new
.
execute
(
user_project
,
params
[
:sha
],
params
[
:format
])
begin
file_path
=
ArchiveRepositoryService
.
new
.
execute
(
user_project
,
params
[
:sha
],
params
[
:format
])
rescue
not_found!
(
'File'
)
end
if
file_path
&&
File
.
exists?
(
file_path
)
data
=
File
.
open
(
file_path
,
'rb'
).
read
header
[
"Content-Disposition"
]
=
"attachment; filename=
\"
#{
File
.
basename
(
file_path
)
}
\"
"
basename
=
File
.
basename
(
file_path
)
header
[
'Content-Disposition'
]
=
"attachment; filename=
\"
#{
basename
}
\"
"
content_type
MIME
::
Types
.
type_for
(
file_path
).
first
.
content_type
env
[
'api.format'
]
=
:binary
present
data
...
...
@@ -161,7 +177,12 @@ module API
get
':id/repository/contributors'
do
authorize!
:download_code
,
user_project
present
user_project
.
repository
.
contributors
,
with:
Entities
::
Contributor
begin
present
user_project
.
repository
.
contributors
,
with:
Entities
::
Contributor
rescue
not_found!
end
end
end
end
...
...
spec/requests/api/repositories_spec.rb
浏览文件 @
e9514c50
...
...
@@ -101,6 +101,14 @@ describe API::API, api: true do
json_response
.
first
[
'type'
].
should
==
'tree'
json_response
.
first
[
'mode'
].
should
==
'040000'
end
it
'should return a 404 for unknown ref'
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/tree?ref_name=foo"
,
user
)
response
.
status
.
should
==
404
json_response
.
should
be_an
Object
json_response
[
'message'
]
==
'404 Tree Not Found'
end
end
context
"unauthorized user"
do
...
...
@@ -145,6 +153,14 @@ describe API::API, api: true do
get
api
(
"/projects/
#{
project
.
id
}
/repository/raw_blobs/
#{
sample_blob
.
oid
}
"
,
user
)
response
.
status
.
should
==
200
end
it
'should return a 404 for unknown blob'
do
get
api
(
"/projects/
#{
project
.
id
}
/repository/raw_blobs/123456"
,
user
)
response
.
status
.
should
==
404
json_response
.
should
be_an
Object
json_response
[
'message'
]
==
'404 Blob Not Found'
end
end
describe
"GET /projects/:id/repository/archive(.:format)?:sha"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录