From e6e70541b8625a29cf407cd7295300bc84acc435 Mon Sep 17 00:00:00 2001 From: Seongmin Lee Date: Thu, 7 May 2026 12:30:43 +0900 Subject: [PATCH] hook/setup: use repoDid path Signed-off-by: Seongmin Lee --- hook/setup.go | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/hook/setup.go b/hook/setup.go index 05d4a4c7..aa4a43da 100644 --- a/hook/setup.go +++ b/hook/setup.go @@ -48,52 +48,28 @@ func Config(opts ...setupOpt) config { // // directory structure is typically like so: // -// did:plc:foobar/repo1 -// did:plc:foobar/repo2 -// did:web:barbaz/repo1 +// did:plc:repo1 +// did:plc:repo2 +// did:web:repo1 func Setup(config config) error { // iterate over all directories in current directory: - userDirs, err := os.ReadDir(config.scanPath) + repoDirs, err := os.ReadDir(config.scanPath) if err != nil { return err } - for _, user := range userDirs { - if !user.IsDir() { + for _, repo := range repoDirs { + if !repo.IsDir() { continue } - did := user.Name() + did := repo.Name() if !strings.HasPrefix(did, "did:") { continue } userPath := filepath.Join(config.scanPath, did) - if err := SetupUser(config, userPath); err != nil { - return err - } - } - - return nil -} - -// setup hooks in /scanpath/did:plc:user -func SetupUser(config config, userPath string) error { - repos, err := os.ReadDir(userPath) - if err != nil { - return err - } - - for _, repo := range repos { - if !repo.IsDir() { - continue - } - - path := filepath.Join(userPath, repo.Name()) - if err := SetupRepo(config, path); err != nil { - if errors.Is(err, ErrNoGitRepo) { - continue - } + if err := SetupRepo(config, userPath); err != nil { return err } } @@ -101,7 +77,7 @@ func SetupUser(config config, userPath string) error { return nil } -// setup hook in /scanpath/did:plc:user/repo +// setup hook in /scanpath/did:plc:repo func SetupRepo(config config, path string) error { if _, err := git.PlainOpen(path); err != nil { return fmt.Errorf("%s: %w", path, ErrNoGitRepo) -- 2.51.2