From 46ae4af9cdba3e2893eb9691941307ef09d98d04 Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Sun, 10 Dec 2023 11:50:47 -0500 Subject: [PATCH] Auto-select project if singular after merge --- README.md | 2 +- cmd/project_go.go | 2 +- cmd/util_fzf.go | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eee334d..1c6054e 100644 --- a/README.md +++ b/README.md @@ -49,5 +49,5 @@ The basic workflow looks like this: - [ ] Make a Makefile - [ ] Add git repo status to project go (up-to-date, pending commits, etc..) - [x] Merge aliases together for same project when selecting - - [ ] If after merging there is only one project, go there by default + - [x] If after merging there is only one project, go there by default diff --git a/cmd/project_go.go b/cmd/project_go.go index b7fb3cf..35ec27c 100644 --- a/cmd/project_go.go +++ b/cmd/project_go.go @@ -24,7 +24,7 @@ func projectGoCmdRun(cmd *cobra.Command, args []string) { if len(args) > 0 { term = args[0] } - // project := getProject(args) + project := fzfSearchProjectAliases(term) if project == nil { diff --git a/cmd/util_fzf.go b/cmd/util_fzf.go index 9e5b7fd..3495e2b 100644 --- a/cmd/util_fzf.go +++ b/cmd/util_fzf.go @@ -77,6 +77,9 @@ func fzfAliasFromAliases(ctx context.Context, aliases []*projects.ProjectAlias) func fzfProjectFromAliases(ctx context.Context, aliases []*projects.ProjectAlias) ( *gitlab.Project, error) { mergedProjects := projectsFromAliases(aliases) + if len(mergedProjects) == 1 { + return mergedProjects[0], nil + } return fzfProjectFromProjects(ctx, mergedProjects) }