Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
522c0197
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
522c0197
编写于
6月 10, 2019
作者:
P
Phil Hughes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add LFS blob ID to GraphQL blob type
上级
25420de6
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
87 addition
and
2 deletion
+87
-2
app/assets/javascripts/repository/components/table/index.vue
app/assets/javascripts/repository/components/table/index.vue
+1
-0
app/assets/javascripts/repository/components/table/row.vue
app/assets/javascripts/repository/components/table/row.vue
+12
-0
app/assets/javascripts/repository/queries/getFiles.graphql
app/assets/javascripts/repository/queries/getFiles.graphql
+1
-0
app/graphql/types/tree/blob_type.rb
app/graphql/types/tree/blob_type.rb
+3
-0
app/presenters/blob_presenter.rb
app/presenters/blob_presenter.rb
+1
-1
changelogs/unreleased/add-lfs-blob-ids-to-tree-type.yml
changelogs/unreleased/add-lfs-blob-ids-to-tree-type.yml
+5
-0
lib/gitlab/graphql/loaders/batch_commit_loader.rb
lib/gitlab/graphql/loaders/batch_commit_loader.rb
+25
-0
spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap
...epository/components/table/__snapshots__/row_spec.js.snap
+2
-0
spec/frontend/repository/components/table/row_spec.js
spec/frontend/repository/components/table/row_spec.js
+13
-0
spec/graphql/types/tree/blob_type_spec.rb
spec/graphql/types/tree/blob_type_spec.rb
+1
-1
spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb
spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb
+23
-0
未找到文件。
app/assets/javascripts/repository/components/table/index.vue
浏览文件 @
522c0197
...
...
@@ -135,6 +135,7 @@ export default {
:path="entry.flatPath"
:type="entry.type"
:url="entry.webUrl"
:lfs-oid="entry.lfsOid"
/>
</
template
>
</tbody>
...
...
app/assets/javascripts/repository/components/table/row.vue
浏览文件 @
522c0197
<
script
>
import
{
GlBadge
}
from
'
@gitlab/ui
'
;
import
{
getIconName
}
from
'
../../utils/icon
'
;
import
getRefMixin
from
'
../../mixins/get_ref
'
;
export
default
{
components
:
{
GlBadge
,
},
mixins
:
[
getRefMixin
],
props
:
{
id
:
{
...
...
@@ -26,6 +30,11 @@ export default {
required
:
false
,
default
:
null
,
},
lfsOid
:
{
type
:
String
,
required
:
false
,
default
:
null
,
},
},
computed
:
{
routerLinkTo
()
{
...
...
@@ -67,6 +76,9 @@ export default {
<component
:is=
"linkComponent"
:to=
"routerLinkTo"
:href=
"url"
class=
"str-truncated"
>
{{
fullPath
}}
</component>
<gl-badge
v-if=
"lfsOid"
variant=
"default"
class=
"label-lfs ml-1"
>
LFS
</gl-badge>
<template
v-if=
"isSubmodule"
>
@
<a
href=
"#"
class=
"commit-sha"
>
{{
shortSha
}}
</a>
</
template
>
...
...
app/assets/javascripts/repository/queries/getFiles.graphql
浏览文件 @
522c0197
...
...
@@ -45,6 +45,7 @@ query getFiles(
node
{
...
TreeEntry
webUrl
lfsOid
}
}
pageInfo
{
...
...
app/graphql/types/tree/blob_type.rb
浏览文件 @
522c0197
...
...
@@ -9,6 +9,9 @@ module Types
graphql_name
'Blob'
field
:web_url
,
GraphQL
::
STRING_TYPE
,
null:
true
field
:lfs_oid
,
GraphQL
::
STRING_TYPE
,
null:
true
,
resolve:
->
(
blob
,
args
,
ctx
)
do
Gitlab
::
Graphql
::
Loaders
::
BatchCommitLoader
.
new
(
blob
.
repository
,
blob
.
id
).
find
end
end
end
end
app/presenters/blob_presenter.rb
浏览文件 @
522c0197
# frozen_string_literal: true
class
BlobPresenter
<
Gitlab
::
View
::
Presenter
::
Simple
class
BlobPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
presents
:blob
def
highlight
(
plain:
nil
)
...
...
changelogs/unreleased/add-lfs-blob-ids-to-tree-type.yml
0 → 100644
浏览文件 @
522c0197
---
title
:
Add LFS oid to GraphQL blob type
merge_request
:
28666
author
:
type
:
added
lib/gitlab/graphql/loaders/batch_commit_loader.rb
0 → 100644
浏览文件 @
522c0197
# frozen_string_literal: true
module
Gitlab
module
Graphql
module
Loaders
class
BatchCommitLoader
def
initialize
(
repository
,
blob_id
)
@repository
,
@blob_id
=
repository
,
blob_id
end
def
find
BatchLoader
.
for
(
blob_id
).
batch
(
key:
repository
)
do
|
blob_ids
,
loader
,
batch_args
|
Gitlab
::
Git
::
Blob
.
batch_lfs_pointers
(
batch_args
[
:key
],
blob_ids
).
each
do
|
loaded_blob
|
loader
.
call
(
loaded_blob
.
id
,
loaded_blob
.
lfs_oid
)
end
end
end
private
attr_reader
:repository
,
:blob_id
end
end
end
end
spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap
浏览文件 @
522c0197
...
...
@@ -22,6 +22,8 @@ exports[`Repository table row component renders table row 1`] = `
</a>
<!---->
<!---->
</td>
<td
...
...
spec/frontend/repository/components/table/row_spec.js
浏览文件 @
522c0197
import
{
shallowMount
,
RouterLinkStub
}
from
'
@vue/test-utils
'
;
import
{
GlBadge
}
from
'
@gitlab/ui
'
;
import
TableRow
from
'
~/repository/components/table/row.vue
'
;
let
vm
;
...
...
@@ -98,4 +99,16 @@ describe('Repository table row component', () => {
expect
(
vm
.
find
(
'
a
'
).
attributes
(
'
href
'
)).
toEqual
(
'
https://test.com
'
);
});
it
(
'
renders LFS badge
'
,
()
=>
{
factory
({
id
:
'
1
'
,
path
:
'
test
'
,
type
:
'
commit
'
,
currentPath
:
'
/
'
,
lfsOid
:
'
1
'
,
});
expect
(
vm
.
find
(
GlBadge
).
exists
()).
toBe
(
true
);
});
});
spec/graphql/types/tree/blob_type_spec.rb
浏览文件 @
522c0197
...
...
@@ -5,5 +5,5 @@ require 'spec_helper'
describe
Types
::
Tree
::
BlobType
do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'Blob'
)
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
:id
,
:name
,
:type
,
:path
,
:flat_path
,
:web_url
)
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
:id
,
:name
,
:type
,
:path
,
:flat_path
,
:web_url
,
:lfs_oid
)
}
end
spec/lib/gitlab/graphql/loaders/batch_commit_loader_spec.rb
0 → 100644
浏览文件 @
522c0197
require
'spec_helper'
describe
Gitlab
::
Graphql
::
Loaders
::
BatchCommitLoader
do
include
GraphqlHelpers
set
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:repository
)
{
project
.
repository
}
let
(
:blob
)
{
Gitlab
::
Graphql
::
Representation
::
TreeEntry
.
new
(
repository
.
blob_at
(
'master'
,
'files/lfs/lfs_object.iso'
),
repository
)
}
let
(
:otherblob
)
{
Gitlab
::
Graphql
::
Representation
::
TreeEntry
.
new
(
repository
.
blob_at
(
'master'
,
'README'
),
repository
)
}
describe
'#find'
do
it
'batch-resolves LFS blob IDs'
do
expect
(
Gitlab
::
Git
::
Blob
).
to
receive
(
:batch_lfs_pointers
).
once
.
and_call_original
result
=
batch
do
[
blob
,
otherblob
].
map
{
|
b
|
described_class
.
new
(
repository
,
b
.
id
).
find
}
end
expect
(
result
.
first
).
to
eq
(
blob
.
lfs_oid
)
expect
(
result
.
last
).
to
eq
(
nil
)
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录