feat(repo): accept full entire:// clone URLs verbatim · Entire

feat(repo): accept full entire:// clone URLs verbatim

fe14a2c→main·

toothbrush·2w ago·2 files·+55 added/-10 removed

A full entire:///gh// URL already names the cluster, so pass it straight to git clone with no mirror lookup. The /gh// shorthand keeps its lookup + cluster resolution.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

Sessions

0efb5fe3a90dView transcript

[?
Add Entire Repo Clone CommandClaude Code·Opus 4.8[1m]·1 step](/content/gh/entireio/cli/session/e77355db-5c1c-4286-94f0-431cf4b77954#timeline-0efb5fe3a90d/index.html)

Changes

2

28 unmodified lines

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
26 unmodified lines

72
73
74
64
65
66
67
68
75
76
77
78
79
80
81
82
83
84
85
71
86
87
88
89
90
75
76
77
78
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111

28 unmodified lines

// borrowing a constant named for an unrelated (checkpoint) concern.
const mirrorCloneProviderGitHub = "github"

// entireCloneURLScheme is the scheme of a full mirror clone URL, which
// git-remote-entire resolves directly. Such a URL already names the cluster, so
// `entire clone` passes it through to `git clone` untouched.
const entireCloneURLScheme = "entire://"

// isEntireCloneURL reports whether ref is a full entire:// clone URL (vs. the
// `/gh/<owner>/<repo>` shorthand that needs a mirror lookup).
func isEntireCloneURL(ref string) bool {
    return strings.HasPrefix(strings.TrimSpace(ref), entireCloneURLScheme)
}

// parseMirrorCloneRef turns a clone ref like `/gh/entirehq/entire-api` into the
// API provider ("github") and the lowercased owner/repo. The `gh` token is the
// path provider used in entire:// clone URLs; it maps to the "github" upstream
26 unmodified lines

cmd := &cobra.Command{
        Use:   "clone <repo> [target-dir]",
        Short: "Clone a mirrored repository",
        Long: "Clone a GitHub mirror by its `/gh/<owner>/<repo>` ref. Looks up where " +
        "the repo is mirrored: if it's on a single cluster, clones it directly; " +
        "if it's mirrored on more than one, prompts you to pick which to clone " +
        "from (or pass --cluster to choose non-interactively). The optional " +
        "[target-dir] is passed straight through to `git clone`.",
        Example: "  entire repo clone /gh/entirehq/entire-api\n" +
        "  entire repo clone /gh/entirehq/entire-api ./entire-api\n" +
        "  entire repo clone /gh/entirehq/entire-api --cluster aws-us-east-2.entire.io",
        "  entire repo clone /gh/entirehq/entire-api --cluster aws-us-east-2.entire.io\n" +
        "  entire repo clone entire://aws-us-east-2.entire.io/gh/entirehq/entire-api",
        Args: cobra.RangeArgs(1, 2),
        RunE: func(cmd *cobra.Command, args []string) error {
            cmd.SilenceUsage = true
            provider, owner, repo, err := parseMirrorCloneRef(args[0])
            if err != nil {
                return fmt.Errorf("invalid <repo>: %w", err)
            }
            ref := args[0]
            var targetDir string
            if len(args) > 1 {
                targetDir = args[1]
            }

// A full entire:// clone URL already embeds the cluster host (it's what
            // --cluster would otherwise resolve to), so pass it verbatim to git clone
            // — no mirror lookup or cluster resolution. --cluster is irrelevant here.
            if isEntireCloneURL(ref) {
                return runGitClone(cmd.Context(), cmd, ref, targetDir)
            }

provider, owner, repo, err := parseMirrorCloneRef(ref)
            if err != nil {
                return fmt.Errorf("invalid <repo>: %w", err)
            }

var mirrors []coreapi.Mirror
            lister := func(ctx context.Context, c *coreapi.Client) error {
                ms, err := listMirrorsForRepo(ctx, c, provider, owner, repo)

Mcmd/entire/cli/repo_clone.go+35/-10

45 unmodified lines

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

45 unmodified lines

}

func TestIsEntireCloneURL(t *testing.T) {
    t.Parallel()
    tests := []struct {
        ref  string
        want bool
    }{
        {ref: "entire://aws-us-east-2.entire.io/gh/entirehq/entire-api", want: true},
        {ref: "  entire://host/gh/a/b", want: true},
        {ref: "/gh/entirehq/entire-api", want: false},
        {ref: "gh/entirehq/entire-api", want: false},
        {ref: "https://github.com/entirehq/entire-api", want: false},
    }
    for _, tt := range tests {
        t.Run(tt.ref, func(t *testing.T) {
            t.Parallel()
        trequire.Equal(t, tt.want, isEntireCloneURL(tt.ref))
        })
    }
}

func TestMirrorCellLabel(t *testing.T) {
    t.Parallel()
    tests := []struct {