@@ -70,6 +70,7 @@ func IsValidScheme(scheme string) bool {
70
70
// do a git-based clone with a token.
71
71
type CustomGitHubDetector struct {
72
72
AtmosConfig schema.AtmosConfiguration
73
+ source string
73
74
}
74
75
75
76
// Detect implements the getter.Detector interface for go-getter v1.
@@ -99,11 +100,10 @@ func (d *CustomGitHubDetector) Detect(src, _ string) (string, bool, error) {
99
100
return "" , false , fmt .Errorf ("invalid GitHub URL %q" , parsedURL .Path )
100
101
}
101
102
102
- if ! strings .Contains (parsedURL .Path , "//" ) {
103
- // If it ends with .git treat it as wanting the entire repo
104
- if strings .HasSuffix (parsedURL .Path , ".git" ) ||
105
- len (parts ) == 3 { // means /owner/repo only
106
- u .LogDebug (d .AtmosConfig , "Detected top-level repo with no subdir: appending '//.\n " )
103
+ if ! strings .Contains (d .source , "//" ) {
104
+ // means user typed something like "github.com/org/repo.git" with NO subdir
105
+ if strings .HasSuffix (parsedURL .Path , ".git" ) || len (parts ) == 3 {
106
+ u .LogDebug (d .AtmosConfig , "Detected top-level repo with no subdir: appending '//.'\n " )
107
107
parsedURL .Path = parsedURL .Path + "//."
108
108
}
109
109
}
@@ -148,19 +148,10 @@ func (d *CustomGitHubDetector) Detect(src, _ string) (string, bool, error) {
148
148
149
149
// RegisterCustomDetectors prepends the custom detector so it runs before
150
150
// the built-in ones. Any code that calls go-getter should invoke this.
151
- func RegisterCustomDetectors (atmosConfig schema.AtmosConfiguration ) {
151
+ func RegisterCustomDetectors (atmosConfig schema.AtmosConfiguration , source string ) {
152
152
getter .Detectors = append (
153
153
[]getter.Detector {
154
- & CustomGitHubDetector {AtmosConfig : atmosConfig },
155
- },
156
- getter .Detectors ... ,
157
- )
158
- }
159
-
160
- func RegisterCustomGetters (atmosConfig schema.AtmosConfiguration ) {
161
- getter .Detectors = append (
162
- []getter.Detector {
163
- & CustomGitHubDetector {AtmosConfig : atmosConfig },
154
+ & CustomGitHubDetector {AtmosConfig : atmosConfig , source : source },
164
155
},
165
156
getter .Detectors ... ,
166
157
)
@@ -176,8 +167,12 @@ func GoGetterGet(
176
167
) error {
177
168
ctx , cancel := context .WithTimeout (context .Background (), timeout )
178
169
defer cancel ()
179
- // Register custom detectors
180
- RegisterCustomDetectors (atmosConfig )
170
+
171
+ // Register custom detectors, passing the original `src` to the CustomGitHubDetector.
172
+ // go-getter typically strips subdirectories before calling the detector, so the
173
+ // unaltered source is needed to identify whether a top-level repository or a
174
+ // subdirectory was specified (e.g., for appending "//." only when no subdir is present).
175
+ RegisterCustomDetectors (atmosConfig , src )
181
176
182
177
client := & getter.Client {
183
178
Ctx : ctx ,
0 commit comments