feat: add per-remote LFS scoping via install --remote#64
Open
thevinchi wants to merge 1 commit into
Open
Conversation
Adds \`git-lfs-s3 install --remote <name>\` to scope the LFS transfer agent to a single S3 remote. Fixes coexistence with non-S3 LFS remotes that break when lfs.standalonetransferagent is configured globally. - Writes remote.<name>.lfsurl and lfs.<url>.standalonetransferagent instead of the global lfs.standalonetransferagent - Bare install preserved (back-compat) with a warning when multiple remotes are configured - Switches --add to --replace-all for idempotency in both paths - 11 new tests; updated README
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #32
Description of changes:
git-lfs-s3 installsetslfs.standalonetransferagentglobally, so git-lfs invokesgit-lfs-s3for every remote in the repo. Any push/pull to a non-S3 remote that uses LFS (GitHub, GitLab, etc.) fails because the agent rejects non-S3 URLs.The root cause is that git-lfs parses
s3://as a bare SSH URL and attempts SSH endpoint discovery before consulting per-URL scoped agent config, so the existing workaround of writinglfs.<s3-url>.standalonetransferagentnever takes effect (lfsapi/endpoint_finder.go:234-274,tq/manifest.go:270-284).This PR adds
git-lfs-s3 install --remote <name>, which setsremote.<name>.lfsurlto a synthetic HTTPS URL (https://lfs-alias.git-remote-s3.test/<bucket>/<prefix>).RemoteEndpoint()checkslfsurlbefore falling back to the remote URL, so the HTTPS-shaped value short-circuits SSH discovery. The scoped agent lookup then finds the per-URLstandalonetransferagentand selectsgit-lfs-s3for that remote only. The synthetic URL is never contacted (IsStandaloneTransfer()skips the LFS server entirely); the.testTLD is RFC 6761-reserved for non-resolvable use.Changes:
git_remote_s3/common.py— addsLFS_ALIAS_HOSTconstant andsynthetic_lfs_url(bucket, prefix)helper.git_remote_s3/lfs.pyinstall()to accept an optional--remote <name>argument._install_unscoped()— preserves existing behavior; adds a stderr warning when more than one remote is configured._install_scoped()— writesremote.<name>.lfsurl,lfs.<url>.standalonetransferagent, andlfs.customtransfer.git-lfs-s3.pathscoped to the named remote; errors iflfsurlis already set to a conflicting value; warns if unscopedlfs.standalonetransferagentis already set.--add(non-idempotent) to--replace-all._git_config_get,_git_config_set,_list_git_remotes,_resolve_s3_remotehelpers.test/lfs_install_test.py(new) — 11 tests using real temp git repos:--remotenonexistent remote → exit 1.--remotenon-S3 remote → exit 1.--remotehappy path (s3://) → three scoped keys, no global agent key.--remotehappy path (s3+zip://) → same.lfsurl→ exit 1, original value preserved.synthetic_lfs_urlgolden-value and RFC-reserved-TLD tests.README.md— updates LFS section to recommend--remote; documents the scoped install form and explains the synthetic URL; updates code examples.Verification:
pytest test/— 59 passed (the pre-existingtest_simultaneous_pushes_single_bundle_remainsfailure onmainis unrelated to this change).black --check— clean on changed files.flake8— clean on changed files.mypy— same 4 pre-existing errors asmain; no new errors introduced.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.