Skip to content

Commit

Permalink
Remove default_path support in repoPaths configuration
Browse files Browse the repository at this point in the history
Now that we support the more general `:owner/:repo` template
configuration (85a75fe), the prior
`default_path` functionality (d9ef14a)
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.
  • Loading branch information
rmacklin committed Mar 7, 2024
1 parent 85a75fe commit a6afac3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions ui/common/repopath.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package common

import (
"fmt"
"path/filepath"
"strings"
)

Expand Down Expand Up @@ -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
}
8 changes: 4 additions & 4 deletions ui/common/repopath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit a6afac3

Please sign in to comment.