Bugfix: Fixes Head/Pipeline
We should prefer `head_pipeline` per Gitlab's documentation.
This commit is contained in:
@@ -7,19 +7,26 @@ local job = require("gitlab.job")
|
|||||||
local u = require("gitlab.utils")
|
local u = require("gitlab.utils")
|
||||||
local M = {
|
local M = {
|
||||||
pipeline_jobs = nil,
|
pipeline_jobs = nil,
|
||||||
pipeline_popup = nil
|
pipeline_popup = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- The function will render the Pipeline state in a popup
|
local function get_pipeline()
|
||||||
M.open = function()
|
local pipeline = state.INFO.head_pipeline or state.INFO.pipeline
|
||||||
local pipeline = state.INFO.pipeline
|
|
||||||
|
|
||||||
if type(pipeline) ~= "table" or (type(pipeline) == "table" and u.table_size(pipeline) == 0) then
|
if type(pipeline) ~= "table" or (type(pipeline) == "table" and u.table_size(pipeline) == 0) then
|
||||||
vim.notify("Pipeline not found", vim.log.levels.WARN)
|
vim.notify("Pipeline not found", vim.log.levels.WARN)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
return pipeline
|
||||||
|
end
|
||||||
|
|
||||||
local body = { pipeline_id = state.INFO.pipeline.id }
|
-- The function will render the Pipeline state in a popup
|
||||||
|
M.open = function()
|
||||||
|
local pipeline = get_pipeline()
|
||||||
|
if not pipeline then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local body = { pipeline_id = pipeline.id }
|
||||||
job.run_job("/pipeline", "GET", body, function(data)
|
job.run_job("/pipeline", "GET", body, function(data)
|
||||||
local pipeline_jobs = u.reverse(type(data.Jobs) == "table" and data.Jobs or {})
|
local pipeline_jobs = u.reverse(type(data.Jobs) == "table" and data.Jobs or {})
|
||||||
M.pipeline_jobs = pipeline_jobs
|
M.pipeline_jobs = pipeline_jobs
|
||||||
@@ -66,15 +73,19 @@ M.open = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
M.retrigger = function()
|
M.retrigger = function()
|
||||||
local body = { pipeline_id = state.INFO.pipeline.id }
|
local pipeline = get_pipeline()
|
||||||
if state.INFO.pipeline.status ~= 'failed' then
|
if not pipeline then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local body = { pipeline_id = pipeline.id }
|
||||||
|
if pipeline.status ~= "failed" then
|
||||||
vim.notify("Pipeline is not in a failed state!", vim.log.levels.WARN)
|
vim.notify("Pipeline is not in a failed state!", vim.log.levels.WARN)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
job.run_job("/pipeline", "POST", body, function(data)
|
job.run_job("/pipeline", "POST", body, function(data)
|
||||||
vim.notify("Pipeline re-triggered!", vim.log.levels.INFO)
|
vim.notify("Pipeline re-triggered!", vim.log.levels.INFO)
|
||||||
state.INFO.pipeline = data.Pipeline
|
pipeline = data.Pipeline
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user