Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
125 lines
3.7 KiB
Go
125 lines
3.7 KiB
Go
package doltutil
|
|
|
|
import "testing"
|
|
|
|
func TestShellQuote(t *testing.T) {
|
|
tests := []struct {
|
|
input string
|
|
want string
|
|
}{
|
|
{"simple", "'simple'"},
|
|
{"has space", "'has space'"},
|
|
{"semi;colon", "'semi;colon'"},
|
|
{"pipe|char", "'pipe|char'"},
|
|
{"$(cmd)", "'$(cmd)'"},
|
|
{"`cmd`", "'`cmd`'"},
|
|
{"it's", "'it'\\''s'"},
|
|
{"", "''"},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.input, func(t *testing.T) {
|
|
if got := ShellQuote(tt.input); got != tt.want {
|
|
t.Errorf("ShellQuote(%q) = %q, want %q", tt.input, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestIsSSHURL(t *testing.T) {
|
|
tests := []struct {
|
|
url string
|
|
want bool
|
|
}{
|
|
// SSH URLs
|
|
{"git+ssh://git@github.com/org/repo.git", true},
|
|
{"ssh://git@github.com/org/repo.git", true},
|
|
{"git@github.com:org/repo.git", true},
|
|
{"git+ssh://github.com/org/repo", true},
|
|
{"ssh://user@host:2222/path", true},
|
|
{"git@bitbucket.org:team/repo.git", true},
|
|
|
|
// Non-SSH URLs
|
|
{"https://dolthub.com/org/repo", false},
|
|
{"http://localhost:50051/repo", false},
|
|
{"aws://[table:bucket]/db", false},
|
|
{"gs://bucket/db", false},
|
|
{"file:///local/path", false},
|
|
{"/absolute/local/path", false},
|
|
{"", false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.url, func(t *testing.T) {
|
|
if got := IsSSHURL(tt.url); got != tt.want {
|
|
t.Errorf("IsSSHURL(%q) = %v, want %v", tt.url, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestIsGitProtocolURL(t *testing.T) {
|
|
tests := []struct {
|
|
url string
|
|
want bool
|
|
}{
|
|
// SSH URLs (subset of git protocol)
|
|
{"git+ssh://git@github.com/org/repo.git", true},
|
|
{"ssh://git@github.com/org/repo.git", true},
|
|
{"git@github.com:org/repo.git", true},
|
|
|
|
// Git-over-HTTPS (the bug: these were not detected before)
|
|
{"git+https://github.com/user/repo.git", true},
|
|
{"git+https://github.com/org/private-repo.git", true},
|
|
|
|
// Git-over-HTTP
|
|
{"git+http://localhost:3000/user/repo.git", true},
|
|
|
|
// Local git transport
|
|
{"git+file:///tmp/repo.git", true},
|
|
|
|
// Plain git protocol
|
|
{"git://github.com/org/repo.git", true},
|
|
|
|
// Non-git-protocol URLs (native Dolt remotes — fast, no CLI needed)
|
|
{"https://dolthub.com/org/repo", false},
|
|
{"https://doltremoteapi.dolthub.com/org/repo", false},
|
|
{"http://localhost:50051/repo", false},
|
|
{"aws://[table:bucket]/db", false},
|
|
{"gs://bucket/db", false},
|
|
{"file:///local/path", false},
|
|
{"/absolute/local/path", false},
|
|
{"", false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.url, func(t *testing.T) {
|
|
if got := IsGitProtocolURL(tt.url); got != tt.want {
|
|
t.Errorf("IsGitProtocolURL(%q) = %v, want %v", tt.url, got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|
|
func TestRemoteURLsMatchNormalizesGitURLs(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
got string
|
|
want string
|
|
ok bool
|
|
}{
|
|
{"exact", "git+https://github.com/org/repo.git", "git+https://github.com/org/repo.git", true},
|
|
{"https normalizes", "https://github.com/org/repo.git", "git+https://github.com/org/repo.git", true},
|
|
{"ssh normalizes", "ssh://git@github.com/org/repo.git", "git+ssh://git@github.com/org/repo.git", true},
|
|
{"scp normalizes", "git@github.com:org/repo.git", "git+ssh://git@github.com/org/repo.git", true},
|
|
{"file native and git transport differ", "git+file:///tmp/repo.git", "file:///tmp/repo.git", false},
|
|
{"file native and git transport differ reversed", "file:///tmp/repo.git", "git+file:///tmp/repo.git", false},
|
|
{"unknown git prefix differs", "git+foo://host/repo", "foo://host/repo", false},
|
|
{"different", "git+https://github.com/org/other.git", "git+https://github.com/org/repo.git", false},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := RemoteURLsMatch(tt.got, tt.want); got != tt.ok {
|
|
t.Errorf("RemoteURLsMatch(%q, %q) = %v, want %v", tt.got, tt.want, got, tt.ok)
|
|
}
|
|
})
|
|
}
|
|
}
|