Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type PluginOptions struct {
GitlabRequest bool `json:"gitlab_request"`
GitlabResponse bool `json:"gitlab_response"`
} `json:"debug"`
ChosenTargetBranch *string `json:"chosen_target_branch,omitempty"`
ChosenMrIID int `json:"chosen_mr_iid"`
ConnectionSettings struct {
Insecure bool `json:"insecure"`
Remote string `json:"remote"`
Expand Down
5 changes: 4 additions & 1 deletion cmd/app/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func (m withMrMiddleware) handle(next http.Handler) http.Handler {
options := gitlab.ListProjectMergeRequestsOptions{
Scope: gitlab.Ptr("all"),
SourceBranch: &m.data.gitInfo.BranchName,
TargetBranch: pluginOptions.ChosenTargetBranch,
}

if pluginOptions.ChosenMrIID != 0 {
options.IIDs = gitlab.Ptr([]int{pluginOptions.ChosenMrIID})
}

mergeRequests, _, err := m.client.ListProjectMergeRequests(m.data.projectInfo.ProjectId, &options)
Expand Down
2 changes: 1 addition & 1 deletion lua/gitlab/actions/merge_requests.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ M.choose_merge_request = function(opts)
end

vim.schedule(function()
state.chosen_target_branch = choice.target_branch
state.chosen_mr_iid = choice.iid
require("gitlab.server").restart(function()
if opts.open_reviewer then
require("gitlab").review()
Expand Down
4 changes: 2 additions & 2 deletions lua/gitlab/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ M.start = function(callback)
debug = state.settings.debug,
log_path = state.settings.log_path,
connection_settings = state.settings.connection_settings,
chosen_target_branch = state.chosen_target_branch,
chosen_mr_iid = state.chosen_mr_iid,
}

state.chosen_target_branch = nil -- Do not let this interfere with subsequent reviewer.open() calls
state.chosen_mr_iid = 0 -- Do not let this interfere with subsequent reviewer.open() calls

local settings = vim.json.encode(go_server_settings)
local command = string.format("%s '%s'", state.settings.bin, settings)
Expand Down
5 changes: 2 additions & 3 deletions lua/gitlab/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,8 @@ M.unlinked_discussion_tree = {
unresolved_expanded = false,
}

-- Used to set a specific target when choosing a merge request, due to the fact
-- that it's technically possible to have multiple target branches
M.chosen_target_branch = nil
-- Used to set a specific MR when choosing a merge request
M.chosen_mr_iid = 0

-- These keymaps are set globally when the plugin is initialized
M.set_global_keymaps = function()
Expand Down