From a6afac3132f6a6aaa8d4c3f2d245a3a7df82f98a Mon Sep 17 00:00:00 2001 From: Richard Macklin Date: Wed, 6 Mar 2024 23:40:19 -0800 Subject: [PATCH] Remove `default_path` support in `repoPaths` configuration Now that we support the more general `:owner/:repo` template configuration (85a75fe07746eae0168546924c4f3861c3e7de5e), the prior `default_path` functionality (d9ef14a2f42d423de32b989b3cf79f9bd9eb4444) is redundant - e.g. this configuration: ``` default_path: ~/code/repos ``` can be achieved equivalently with: ``` :owner/:repo: ~/code/repos/:repo ``` Thus, we are removing the `default_path` syntax. --- README.md | 4 ++-- ui/common/repopath.go | 6 ------ ui/common/repopath_test.go | 8 ++++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 1bfa92ce..8c0302ed 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,6 @@ defaults: width: 60 # width in columns refetchIntervalMinutes: 30 # will refetch all sections every 30 minutes repoPaths: # configure where to locate repos when checking out PRs - default_path: ~/code/repos # fallback value if none of the other paths match :owner/:repo: ~/src/github.com/:owner/:repo # template if you always clone github repos in a consistent location dlvhdr/*: ~/code/repos/dlvhdr/* # will match dlvhdr/repo-name to ~/code/repos/dlvhdr/repo-name dlvhdr/gh-dash: ~/code/gh-dash # will not match wildcard and map to specified path @@ -214,9 +213,10 @@ Repo name to path mappings can be exact match (full name, full path) or wildcard An exact match for the full repo name to a full path takes priority over a matching wildcard, and wildcard matches must match to a wildcard path. +An `:owner/:repo` template can be specified as a generic fallback. + ```yaml repoPaths: - default_path: ~/code/repos # fallback value if none of the other paths match :owner/:repo: ~/src/github.com/:owner/:repo # template if you always clone github repos in a consistent location dlvhdr/*: ~/code/repos/dlvhdr/* # will match dlvhdr/repo-name to ~/code/repos/dlvhdr/repo-name dlvhdr/gh-dash: ~/code/gh-dash # will not match wildcard and map to specified path diff --git a/ui/common/repopath.go b/ui/common/repopath.go index e7aa4659..9b2e706b 100644 --- a/ui/common/repopath.go +++ b/ui/common/repopath.go @@ -2,7 +2,6 @@ package common import ( "fmt" - "path/filepath" "strings" ) @@ -52,10 +51,5 @@ func GetRepoLocalPath(repoName string, cfgPaths map[string]string) (string, bool return strings.ReplaceAll(strings.ReplaceAll(template, ":owner", owner), ":repo", repo), true } - if defaultPath, found := cfgPaths["default_path"]; found { - p := strings.TrimSuffix(defaultPath, "/*") - return filepath.Join(p, repo), true - } - return "", false } diff --git a/ui/common/repopath_test.go b/ui/common/repopath_test.go index eca0139c..9bf5233d 100644 --- a/ui/common/repopath_test.go +++ b/ui/common/repopath_test.go @@ -13,10 +13,10 @@ var configPaths = map[string]string{ "user_2/*": "/path/to/user_2/*", } -var configPathsWithDefaultPath = map[string]string{ +var configPathsWithOwnerRepoTemplateIgnoringOwner = map[string]string{ "user/repo": "/path/to/user/repo", "user_2/*": "/path/to/user_2/*", - "default_path": "/path/to/user/dev", + ":owner/:repo": "/path/to/user/dev/:repo", } var configPathsWithOwnerRepoTemplate = map[string]string{ @@ -56,11 +56,11 @@ func TestGetRepoLocalPath(t *testing.T) { found: false, configPaths: configPaths, }, - "default path": { + "with :owner/:repo template: ignoring owner substitution": { repo: "user3/repo", want: "/path/to/user/dev/repo", found: true, - configPaths: configPathsWithDefaultPath, + configPaths: configPathsWithOwnerRepoTemplateIgnoringOwner, }, "with :owner/:repo template: exact match": { repo: "user/repo",