FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
gitlab.nvim/lua/gitlab/actions/data.lua at develop · harrisoncramer/gitlab.nvim · GitHub
harrisoncramer
gitlab.nvim
Repository navigation
Code
Issues
12
(12)
Pull requests
5
(5)
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
gitlab.nvim
/
lua
/
gitlab
/
actions
/
data.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (51 loc) · 1.89 KB
Breadcrumbs
gitlab.nvim
/
lua
/
gitlab
/
actions
/
data.lua
Copy path
File metadata and controls
58 lines (51 loc) · 1.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
local
u
=
require
(
"
gitlab.utils
"
)
local
async
=
require
(
"
gitlab.async
"
)
local
state
=
require
(
"
gitlab.state
"
)
local
M
=
{}
local
user
=
state
.
dependencies
.
user
local
info
=
state
.
dependencies
.
info
local
labels
=
state
.
dependencies
.
labels
local
mergeability
=
state
.
dependencies
.
mergeability
local
project_members
=
state
.
dependencies
.
project_members
local
revisions
=
state
.
dependencies
.
revisions
local
latest_pipeline
=
state
.
dependencies
.
latest_pipeline
local
draft_notes
=
state
.
dependencies
.
draft_notes
---
@class
GitlabResource
---
@field
type
"
info
"
|
"
user
"
|
"
labels
"
|
"
mergeability
"
|
"
project_members
"
|
"
revisions
"
|
"
pipeline
"
|
"
draft_notes
"
---
@field
refresh
boolean If true
,
refresh the data by hitting Gitlab
'
s APIs again.
---
Load the data about the current MR, and execute callback with the date as an argument.
---
@param
resources
GitlabResource[]
---
@param
cb
fun
(
data
)
---
@return
nil
M
.
data
=
function
(
resources
,
cb
)
if
type
(
resources
)
~=
"
table
"
or
type
(
cb
)
~=
"
function
"
then
u
.
notify
(
"
The data function must be passed a resources table and a callback function
"
,
vim
.
log
.
levels
.
ERROR
)
return
end
local
all_resources
=
{
info
=
info
,
user
=
user
,
labels
=
labels
,
mergeability
=
mergeability
,
project_members
=
project_members
,
revisions
=
revisions
,
pipeline
=
latest_pipeline
,
draft_notes
=
draft_notes
,
}
local
api_calls
=
{}
for
_
,
resource
in
ipairs
(
resources
)
do
local
api_call
=
all_resources
[
resource
.
type
]
table.insert
(
api_calls
,
u
.
merge
(
api_call
, {
refresh
=
resource
.
refresh
}))
end
--
TODO: Build an async "parallel" that fetches the resources
--
in parallel where possible to speed up this API
return
async
.
sequence
(
api_calls
,
function
()
local
data
=
{}
--
FIXME: Shouldn't this really be `for k, v in pairs(api_calls) do`?
for
k
,
v
in
pairs
(
all_resources
)
do
data
[
k
]
=
state
[
v
.
state
]
end
cb
(
data
)
end
)()
end
return
M
Back
|
FazBrowse Home
|
New Git URL