all repos — searchix @ a5e758d41c151c17ed03b39454470ba8dd0c3b99

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

refactor: separate fetch and import logic

Alan Pearce
commit

a5e758d41c151c17ed03b39454470ba8dd0c3b99

parent

d558039919b6198a246a6a3fd007276191cb4b2f

1 file changed, 22 insertions(+), 0 deletions(-)

changed files
M internal/importer/utils.gointernal/importer/utils.go
@@ -1,11 +1,15 @@
package importer import ( + "bytes" "fmt" "net/url" + "os" + "searchix/internal/config" "searchix/internal/nix" "github.com/bcicen/jstream" + "github.com/pkg/errors" ) func ValueTypeToString(valueType jstream.ValueType) string {
@@ -58,3 +62,21 @@ Name: fmt.Sprintf("<%s/%s>", channel, subPath),
URL: makeGitHubFileURL(channelRepoMap[channel], ref, subPath, ""), }, nil } + +func setRepoRevision(filename string, source *config.Source) error { + if filename != "" { + bits, err := os.ReadFile(filename) + if err != nil { + return errors.WithMessagef( + err, + "unable to read revision file at %s", + filename, + ) + } + + source.Repo.Revision = string(bytes.TrimSpace(bits)) + + } + + return nil +}