@@ -115,7 +115,7 @@ func FetchURL(ctx context.Context, opts ...FetchURLOptions) (string, error) {
115115 // Origin's protocol can't be mapped to a git transport (e.g. entire://,
116116 // file://). Honor the configured checkpoint_remote by targeting the
117117 // provider's canonical host over HTTPS rather than falling back to origin.
118- if providerURL , ok := resolveProviderCheckpointURL (config , originRemote , opt .WorktreeRoot ); ok {
118+ if providerURL , ok := resolveProviderCheckpointURL (config , opt .WorktreeRoot ); ok {
119119 return providerURL , nil
120120 }
121121 logFallback (ctx , "fetch" , originURL , "derive checkpoint remote URL" , err )
@@ -223,7 +223,7 @@ func PushURL(ctx context.Context, pushRemoteName string) (string, bool, error) {
223223 // (e.g. entire://, file://). Honor the configured checkpoint_remote by
224224 // targeting the provider's canonical host over HTTPS rather than
225225 // misrouting checkpoints to the origin remote.
226- if providerURL , ok := resolveProviderCheckpointURL (config , pushRemoteName , "" ); ok {
226+ if providerURL , ok := resolveProviderCheckpointURL (config , "" ); ok {
227227 return providerURL , true , nil
228228 }
229229 fallbackURL , fallbackErr := resolvePushFallbackURL (ctx , pushRemoteName , originURL )
@@ -309,12 +309,6 @@ func deriveCheckpointURLFromInfo(info *Info, config *settings.CheckpointRemoteCo
309309 }
310310}
311311
312- // originalURLConfigKey is the git config option, under remote.<name>., where
313- // entiredb's `entire-repo mirror use` records the URL a remote had before it was
314- // switched to entire://. It is the most faithful record of the endpoint and auth
315- // method the user had for that remote.
316- const originalURLConfigKey = "entiredb-original-url"
317-
318312// resolveProviderCheckpointURL builds the checkpoint URL for the configured
319313// provider, choosing the transport from what's already configured for that
320314// endpoint. It is the fallback used when the push/origin remote's protocol can't
@@ -323,24 +317,21 @@ const originalURLConfigKey = "entiredb-original-url"
323317// than being misrouted to the origin remote.
324318//
325319// Transport precedence:
326- // 1. The remote's pre-mirror URL (remote.<name>.entiredb-original-url) — the
327- // endpoint and scheme the remote used before `entire-repo mirror use`
328- // switched it to entire://. Reused verbatim (host + scheme + port).
329- // 2. ENTIRE_CHECKPOINT_TOKEN set -> HTTPS on the provider host (the token is
320+ // 1. ENTIRE_CHECKPOINT_TOKEN set -> HTTPS on the provider host (the token is
330321// the credential).
331- // 3 . An existing remote already targets the provider host -> reuse its scheme,
322+ // 2 . An existing remote already targets the provider host -> reuse its scheme,
332323// so checkpoints use the same auth the user already has for that endpoint.
333- // 4 . Otherwise SSH on the provider host.
324+ // 3 . Otherwise SSH on the provider host.
334325//
335326// Returns ok=false when no transport can be determined (unknown provider with no
336327// usable signal), in which case the caller falls back to the origin remote.
337- func resolveProviderCheckpointURL (config * settings.CheckpointRemoteConfig , remoteName , dir string ) (string , bool ) {
328+ func resolveProviderCheckpointURL (config * settings.CheckpointRemoteConfig , dir string ) (string , bool ) {
338329 repo , err := openRepoAt (dir )
339330 if err != nil {
340331 repo = nil // Fall back to env/provider-only signals.
341332 }
342333
343- info , ok := pickProviderTransport (repo , config , remoteName )
334+ info , ok := pickProviderTransport (repo , config )
344335 if ! ok {
345336 return "" , false
346337 }
@@ -354,31 +345,22 @@ func resolveProviderCheckpointURL(config *settings.CheckpointRemoteConfig, remot
354345// pickProviderTransport returns the protocol/host/port to use when deriving a
355346// checkpoint URL, following the precedence documented on
356347// resolveProviderCheckpointURL.
357- func pickProviderTransport (repo * git.Repository , config * settings.CheckpointRemoteConfig , remoteName string ) (* Info , bool ) {
358- // 1. The remote's saved pre-mirror URL: the endpoint and auth the user had.
359- if repo != nil {
360- if original := originalRemoteURL (repo , remoteName ); original != "" {
361- if info , err := gitremote .ParseURL (original ); err == nil && isDerivableProtocol (info .Protocol ) {
362- return info , true
363- }
364- }
365- }
366-
348+ func pickProviderTransport (repo * git.Repository , config * settings.CheckpointRemoteConfig ) (* Info , bool ) {
367349 host , hostOK := providerHost (config .Provider )
368350
369- // 2 . Explicit token -> HTTPS on the provider host.
351+ // 1 . Explicit token -> HTTPS on the provider host.
370352 if hostOK && strings .TrimSpace (os .Getenv (CheckpointTokenEnvVar )) != "" {
371353 return & Info {Protocol : ProtocolHTTPS , Host : host }, true
372354 }
373355
374- // 3 . An existing remote already targeting the provider host -> reuse scheme.
356+ // 2 . An existing remote already targeting the provider host -> reuse scheme.
375357 if hostOK && repo != nil {
376358 if info , ok := findRemoteInfoForHost (repo , host ); ok {
377359 return & Info {Protocol : info .Protocol , Host : info .Host , Port : info .Port }, true
378360 }
379361 }
380362
381- // 4 . Default to SSH on the provider host.
363+ // 3 . Default to SSH on the provider host.
382364 if hostOK {
383365 return & Info {Protocol : ProtocolSSH , Host : host }, true
384366 }
@@ -399,16 +381,6 @@ func openRepoAt(dir string) (*git.Repository, error) {
399381 return repo , nil
400382}
401383
402- // originalRemoteURL returns the pre-mirror URL saved by `entire-repo mirror use`
403- // in remote.<name>.entiredb-original-url, or "" when absent.
404- func originalRemoteURL (repo * git.Repository , remoteName string ) string {
405- cfg , err := repo .Config ()
406- if err != nil {
407- return ""
408- }
409- return cfg .Raw .Section ("remote" ).Subsection (remoteName ).Option (originalURLConfigKey )
410- }
411-
412384// findRemoteInfoForHost returns the parsed Info of the first configured git
413385// remote (in deterministic name order) whose host matches host and whose
414386// protocol is a usable git transport (ssh/https). entire:// and other
0 commit comments