@@ -6,6 +6,31 @@ import (
6
6
"strings"
7
7
)
8
8
9
+ func scanGitFolders (root string ) ([]string , error ) {
10
+ var gitFolders []string
11
+ err := filepath .WalkDir (root , func (path string , d fs.DirEntry , err error ) error {
12
+ if err != nil {
13
+ return err
14
+ }
15
+
16
+ if d .IsDir () && d .Name () == ".git" {
17
+ gitFolder := filepath .Dir (path )
18
+ gitFolders = append (gitFolders , gitFolder )
19
+ return filepath .SkipDir // Skip further traversal within this directory
20
+ }
21
+
22
+ // Skip dependency directories
23
+ _ , ok := excludedFolders [strings .ToLower (d .Name ())]
24
+ if d .IsDir () && ok {
25
+ return filepath .SkipDir
26
+ }
27
+
28
+ return nil
29
+ })
30
+
31
+ return gitFolders , err
32
+ }
33
+
9
34
// excludedFolders is a map of folder names (case-insensitive) to be excluded during the scan.
10
35
var excludedFolders = map [string ]struct {}{
11
36
"node_modules" : {},
@@ -40,31 +65,3 @@ var excludedFolders = map[string]struct{}{
40
65
".vagrant" : {},
41
66
".serverless" : {},
42
67
}
43
-
44
- func scanGitFolders (root string ) ([]string , error ) {
45
- var gitFolders []string
46
- err := filepath .WalkDir (root , func (path string , d fs.DirEntry , err error ) error {
47
- if err != nil {
48
- return err
49
- }
50
-
51
- if d .IsDir () && d .Name () == ".git" {
52
- gitFolder := filepath .Dir (path )
53
- gitFolders = append (gitFolders , gitFolder )
54
- return filepath .SkipDir // Skip further traversal within this directory
55
- }
56
-
57
- // Skip dependency directories
58
- _ , ok := excludedFolders [strings .ToLower (d .Name ())]
59
- if d .IsDir () && ok {
60
- return filepath .SkipDir
61
- }
62
-
63
- return nil
64
- })
65
-
66
- if err != nil {
67
- return nil , err
68
- }
69
- return gitFolders , nil
70
- }
0 commit comments