all repos — searchix @ ad670006a58faa22a183212f3b68189b6ab8d5fa

Search engine for NixOS, nix-darwin, home-manager and NUR users

refactor: move repository file URL generation to Repository method

Alan Pearce
commit

ad670006a58faa22a183212f3b68189b6ab8d5fa

parent

b767d7bc25ef13c86c126dbbf39f05604750963c

1 file changed, 1 insertion(+), 23 deletions(-)

changed files
M internal/importer/utils.gointernal/importer/utils.go
@@ -3,7 +3,6 @@
import ( "fmt" "io" - "net/url" "strings" "go.alanpearce.eu/searchix/internal/config"
@@ -34,29 +33,8 @@
return "very strange" } -func makeRepoURL(repo config.Repository, subPath string, line string) (string, errors.E) { - switch repo.Type { - case config.GitHub: - ref := repo.Revision - if ref == "" { - ref = "master" - } - url, _ := url.JoinPath("https://github.com/", repo.Owner, repo.Repo, "blob", ref, subPath) - if line != "" { - url = url + "#L" + line - } - - return url, nil - default: - return "", errors.Errorf( - "don't know how to generate a repository URL for %s", - repo.Type.String(), - ) - } -} - func MakeChannelLink(repo config.Repository, subPath string) (*nix.Link, errors.E) { - url, err := makeRepoURL(repo, subPath, "") + url, err := repo.GetFileURL(subPath) if err != nil { return nil, err }