From b7960ed1b416db14b97173f2391c84664fb336ae Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Mon, 11 Dec 2023 15:54:22 -0500 Subject: [PATCH] Improve project show --current behavior --- cmd/project_show.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmd/project_show.go b/cmd/project_show.go index 43a8c71..1aac2a1 100644 --- a/cmd/project_show.go +++ b/cmd/project_show.go @@ -2,6 +2,7 @@ package cmd import ( "fmt" + "os" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -25,6 +26,7 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) { } var project *gitlab.Project + var inCwd bool // Try to find project from current directory if viper.GetBool("project.show.current") { @@ -37,6 +39,8 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) { )) } else if project == nil { plog.Warn("Failed to use --current flag, project not found in current path") + } else { + inCwd = true } } @@ -63,6 +67,11 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) { WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Project Information"))). Println(cache.ProjectString(project)) fmt.Println() + + if inCwd { + project.SetRepo(cache.OpenProject(cmd.Context(), project)) + fmt.Fprintln(os.Stderr, project.GetGitInfo()+"\n") + } } func init() {