about summary refs log tree commit diff stats
path: root/internal/importer/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/importer/utils.go')
-rw-r--r--internal/importer/utils.go22
1 files changed, 6 insertions, 16 deletions
diff --git a/internal/importer/utils.go b/internal/importer/utils.go
index 1c0d3af..3977c2e 100644
--- a/internal/importer/utils.go
+++ b/internal/importer/utils.go
@@ -36,11 +36,12 @@ func ValueTypeToString(valueType jstream.ValueType) string {
 	return "very strange"
 }
 
-func makeGitHubFileURL(userRepo string, ref string, subPath string, line string) string {
+func makeRepoURL(repo config.Repository, subPath string, line string) string {
+	ref := repo.Revision
 	if ref == "" {
 		ref = "master"
 	}
-	url, _ := url.JoinPath("https://github.com/", userRepo, "blob", ref, subPath)
+	url, _ := url.JoinPath("https://github.com/", repo.Owner, repo.Repo, "blob", ref, subPath)
 	if line != "" {
 		url = url + "#L" + line
 	}
@@ -48,21 +49,10 @@ func makeGitHubFileURL(userRepo string, ref string, subPath string, line string)
 	return url
 }
 
-// make configurable?
-var channelRepoMap = map[string]string{
-	"nixpkgs":      "NixOS/nixpkgs",
-	"nix-darwin":   "LnL7/nix-darwin",
-	"home-manager": "nix-community/home-manager",
-}
-
-func MakeChannelLink(channel string, ref string, subPath string) (*nix.Link, error) {
-	if channelRepoMap[channel] == "" {
-		return nil, fmt.Errorf("don't know what repository relates to channel <%s>", channel)
-	}
-
+func MakeChannelLink(repo config.Repository, subPath string) (*nix.Link, error) {
 	return &nix.Link{
-		Name: fmt.Sprintf("<%s/%s>", channel, subPath),
-		URL:  makeGitHubFileURL(channelRepoMap[channel], ref, subPath, ""),
+		Name: fmt.Sprintf("<%s/%s>", repo.Repo, subPath),
+		URL:  makeRepoURL(repo, subPath, ""),
 	}, nil
 }