Fix MR Selection, Go Code Refactor (#358)

refactor: Refactors the Go codebase into a more modular and idiomatic approach
fix: require selection of specific MR when there are multiple targets for a given source branch
feat: Allows for the passing of Gitlab's filter options when choosing an MR, improves MR selection
feat: API to choose an MR from a list based on the provided username's involvement as an assignee/reviewer/author

This is a #MINOR release
This commit is contained in:
Harrison (Harry) Cramer
2024-09-08 16:45:09 -04:00
committed by GitHub
parent 6500ef1f2c
commit ea2b2b2f5c
81 changed files with 2559 additions and 3035 deletions

View File

@@ -4,47 +4,39 @@ import (
"encoding/json"
"log"
"os"
"github.com/harrisoncramer/gitlab.nvim/cmd/app"
"github.com/harrisoncramer/gitlab.nvim/cmd/app/git"
)
type PluginOptions struct {
GitlabUrl string `json:"gitlab_url"`
Port int `json:"port"`
AuthToken string `json:"auth_token"`
LogPath string `json:"log_path"`
Debug struct {
Request bool `json:"go_request"`
Response bool `json:"go_response"`
} `json:"debug"`
ConnectionSettings struct {
Insecure bool `json:"insecure"`
Remote string `json:"remote"`
} `json:"connection_settings"`
}
var pluginOptions PluginOptions
var pluginOptions app.PluginOptions
func main() {
log.SetFlags(0)
err := json.Unmarshal([]byte(os.Args[1]), &pluginOptions)
app.SetPluginOptions(pluginOptions)
if err != nil {
log.Fatalf("Failure parsing plugin settings: %v", err)
}
gitInfo, err := extractGitInfo(RefreshProjectInfo, GetProjectUrlFromNativeGitCmd, GetCurrentBranchNameFromNativeGitCmd)
gitManager := git.Git{}
gitData, err := git.NewGitData(pluginOptions.ConnectionSettings.Remote, gitManager)
if err != nil {
log.Fatalf("Failure initializing plugin: %v", err)
}
err, client := initGitlabClient()
err, client := app.NewClient()
if err != nil {
log.Fatalf("Failed to initialize Gitlab client: %v", err)
}
err, projectInfo := initProjectSettings(client, gitInfo)
err, projectInfo := app.InitProjectSettings(client, gitData)
if err != nil {
log.Fatalf("Failed to initialize project settings: %v", err)
}
startServer(client, projectInfo, gitInfo)
app.StartServer(client, projectInfo, gitData)
}