Monorepo for Tangled tangled.org
856
fork

Configure Feed

Select the types of activity you want to include in your feed.

hook/setup: use repoDid path #348

open opened by boltless.me targeting master from sl/uytzrkusqmzm
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:xasnlahkri4ewmbuzly2rlc5/sh.tangled.repo.pull/3mlbk3pyh4g22
+9 -33
Diff #0
+9 -33
hook/setup.go
··· 48 48 // 49 49 // directory structure is typically like so: 50 50 // 51 - // did:plc:foobar/repo1 52 - // did:plc:foobar/repo2 53 - // did:web:barbaz/repo1 51 + // did:plc:repo1 52 + // did:plc:repo2 53 + // did:web:repo1 54 54 func Setup(config config) error { 55 55 // iterate over all directories in current directory: 56 - userDirs, err := os.ReadDir(config.scanPath) 56 + repoDirs, err := os.ReadDir(config.scanPath) 57 57 if err != nil { 58 58 return err 59 59 } 60 60 61 - for _, user := range userDirs { 62 - if !user.IsDir() { 61 + for _, repo := range repoDirs { 62 + if !repo.IsDir() { 63 63 continue 64 64 } 65 65 66 - did := user.Name() 66 + did := repo.Name() 67 67 if !strings.HasPrefix(did, "did:") { 68 68 continue 69 69 } 70 70 71 71 userPath := filepath.Join(config.scanPath, did) 72 - if err := SetupUser(config, userPath); err != nil { 73 - return err 74 - } 75 - } 76 - 77 - return nil 78 - } 79 - 80 - // setup hooks in /scanpath/did:plc:user 81 - func SetupUser(config config, userPath string) error { 82 - repos, err := os.ReadDir(userPath) 83 - if err != nil { 84 - return err 85 - } 86 - 87 - for _, repo := range repos { 88 - if !repo.IsDir() { 89 - continue 90 - } 91 - 92 - path := filepath.Join(userPath, repo.Name()) 93 - if err := SetupRepo(config, path); err != nil { 94 - if errors.Is(err, ErrNoGitRepo) { 95 - continue 96 - } 72 + if err := SetupRepo(config, userPath); err != nil { 97 73 return err 98 74 } 99 75 } ··· 101 77 return nil 102 78 } 103 79 104 - // setup hook in /scanpath/did:plc:user/repo 80 + // setup hook in /scanpath/did:plc:repo 105 81 func SetupRepo(config config, path string) error { 106 82 if _, err := git.PlainOpen(path); err != nil { 107 83 return fmt.Errorf("%s: %w", path, ErrNoGitRepo)

History

1 round 0 comments
sign up or login to add to the discussion
boltless.me submitted #0
1 commit
expand
hook/setup: use repoDid path
merge conflicts detected
expand
  • hook/setup.go:48
expand 0 comments