Skip to content

Commit b45ff8b

Browse files
committed
Recognize path queries in SCP Git dependencies
Strip Unity package path queries before checking SCP-style Git dependency suffixes so lockless V2 projects remain eligible for safe cache fallback.
1 parent 3882b19 commit b45ff8b

2 files changed

Lines changed: 26 additions & 3 deletions

File tree

cli/dispatcher/internal/dispatcher/dispatcher_v2_detect.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ func isDispatcherGitPackageDependency(dependency json.RawMessage) bool {
119119
return false
120120
}
121121
withoutRevision, _, _ := strings.Cut(strings.TrimSpace(value), "#")
122-
if strings.HasPrefix(withoutRevision, "git@") {
123-
return strings.HasSuffix(withoutRevision, ".git")
122+
withoutQuery, _, _ := strings.Cut(withoutRevision, "?")
123+
if strings.HasPrefix(withoutQuery, "git@") {
124+
return strings.HasSuffix(withoutQuery, ".git")
124125
}
125-
parsed, err := url.Parse(withoutRevision)
126+
parsed, err := url.Parse(withoutQuery)
126127
if err != nil {
127128
return false
128129
}

cli/dispatcher/internal/dispatcher/dispatcher_v2_detect_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,28 @@ func TestDetectV2DispatcherProjectRejectsNonGitManifestFallbackWithoutLockEntry(
229229
}
230230
}
231231

232+
func TestIsDispatcherGitPackageDependencyAcceptsPathQueries(t *testing.T) {
233+
// Verifies Unity Git dependencies with path queries remain eligible for PackageCache fallback.
234+
testCases := []struct {
235+
name string
236+
dependency string
237+
}{
238+
{name: "scp", dependency: "git@example.invalid:package.git?path=/sub"},
239+
{name: "https", dependency: "https://example.invalid/package.git?path=/sub"},
240+
}
241+
for _, testCase := range testCases {
242+
t.Run(testCase.name, func(t *testing.T) {
243+
dependency, err := json.Marshal(testCase.dependency)
244+
if err != nil {
245+
t.Fatalf("marshal dependency: %v", err)
246+
}
247+
if !isDispatcherGitPackageDependency(dependency) {
248+
t.Fatalf("Git dependency was rejected: %s", testCase.dependency)
249+
}
250+
})
251+
}
252+
}
253+
232254
func TestRunDispatcherReportsV2ProjectGuidanceWhenPinIsMissing(t *testing.T) {
233255
// Verifies pinless V2 projects receive migration guidance instead of the missing-pin error.
234256
projectRoot := createDispatcherUnityProject(t)

0 commit comments

Comments
 (0)