From 2082287bdd4e7caeee453caa6dc32a0f28b26f99 Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Tue, 19 Dec 2023 12:16:45 -0500 Subject: [PATCH] Fix first-time config gen, improve project_go --- cmd/util_constants.go | 2 +- cmd/util_init.go | 3 ++- internal/gitlab/gitlab.go | 13 ++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/util_constants.go b/cmd/util_constants.go index dd0798f..62990d8 100644 --- a/cmd/util_constants.go +++ b/cmd/util_constants.go @@ -1,7 +1,7 @@ package cmd const ( - defGitlabHost = "gitlab.sweetwater.com" + defGitlabHost = "https://gitlab.com" defLogLevel = "info" defConfigPath = "~/.config/gitlab-project-manager.yaml" ) diff --git a/cmd/util_init.go b/cmd/util_init.go index e97e946..ba01ab3 100644 --- a/cmd/util_init.go +++ b/cmd/util_init.go @@ -56,6 +56,7 @@ func initProjectPath(cmd *cobra.Command, args []string) { var err error if conf.ProjectPath == "" { conf.ProjectPath = config.DefaultConfig.ProjectPath + return } if conf.ProjectPath, err = resolvePath(conf.ProjectPath); err != nil { plog.Error("Failed to determine project path", plog.Args("error", err)) @@ -64,7 +65,7 @@ func initProjectPath(cmd *cobra.Command, args []string) { _, err = os.Stat(conf.ProjectPath) if err != nil { plog.Error("Failed to stat project path, trying to create", plog.Args("error", err)) - if err := os.Mkdir(conf.ProjectPath, 0750); err != nil { + if err := os.MkdirAll(conf.ProjectPath, 0750); err != nil { plog.Error("Failed to create project path", plog.Args("error", err)) os.Exit(1) } diff --git a/internal/gitlab/gitlab.go b/internal/gitlab/gitlab.go index 8f9f114..0fa2c3d 100644 --- a/internal/gitlab/gitlab.go +++ b/internal/gitlab/gitlab.go @@ -79,18 +79,25 @@ func (p *Project) GetGitInfo() string { } var str string + str += "\n" + pterm.LightRed("Project: ") + pterm.Bold.Sprint(p.Name) + "\n" head, _ := repo.Head() branch := head.Name().String()[11:] b, _ := repo.Branch(branch) if b != nil { - str = "\n" + pterm.LightCyan("Branch: ") + pterm.Bold.Sprint(b.Name) + "\n" + str += pterm.LightCyan("Branch: ") + pterm.Bold.Sprint(b.Name) + "\n" } else { - str = "\n" + pterm.LightCyan("NEW Branch: ") + pterm.Bold.Sprint(branch) + "\n" + str += pterm.LightCyan("NEW Branch: ") + pterm.Bold.Sprint(branch) + "\n" } commit, _ := repo.CommitObject(head.Hash()) - str += commit.String() + str += "\n" + commit.String() + + str += pterm.LightMagenta("GitLab: ") + pterm.Bold.Sprint(p.HTTPURLToRepo) + "\n" + + if remotes, _ := repo.Remotes(); len(remotes) > 0 { + str += pterm.LightBlue("Remote: ") + pterm.Bold.Sprint(remotes[0].Config().URLs[0]) + } return pterm.DefaultBox. WithLeftPadding(5).WithRightPadding(5).