Detect remote URL when in project
Allow adding a remote by providing just a username/org instead of a full URL. The tool detects the remote URL pattern from the existing origin and constructs the new remote URL automatically.
Breaking change
The -r / --remote flag is repurposed. It now operates on the current repo (CWD) instead of walking GRAB_PATH. A new -R / --remote-all flag provides the walk behaviour.
Flags
-r, --remote Add remote to current repo (CWD)
-R, --remote-all Add remote to all repos in GRAB_PATH (ls-remote verified)
Both flags accept either a full URL or a username:
grab -r Boomatang # CWD: construct URL from origin
grab -r git@github.com:User/repo.git # CWD: use URL as-is
grab -R Boomatang # walk GRAB_PATH: construct URL per repo, ls-remote verify
grab -R git@github.com:User/repo.git # walk GRAB_PATH: add this URL to every matching repo
The flag controls scope, the input controls how the URL is resolved.
URL construction
When a username is provided instead of a full URL, the site and format are derived from the repo's own origin:
- GitHub origin (
git@github.com:SomeOrg/repo.git) → git@github.com:Boomatang/repo.git
- Codeberg origin (
ssh://git@codeberg.org/someone/repo.git) → ssh://git@codeberg.org/Boomatang/repo.git
Edge cases
- Not inside a git repo (CWD mode) → error
- No origin remote exists → error (or allow specifying which remote to use as template)
- Remote with that name already exists → skip with warning
ls-remote fails or times out during GRAB_PATH walk → skip with warning
- Mixed sites in GRAB_PATH → no conflict, each repo derives its site from its own origin
Detect remote URL when in project
Allow adding a remote by providing just a username/org instead of a full URL. The tool detects the remote URL pattern from the existing origin and constructs the new remote URL automatically.
Breaking change
The
-r/--remoteflag is repurposed. It now operates on the current repo (CWD) instead of walking GRAB_PATH. A new-R/--remote-allflag provides the walk behaviour.Flags
Both flags accept either a full URL or a username:
The flag controls scope, the input controls how the URL is resolved.
URL construction
When a username is provided instead of a full URL, the site and format are derived from the repo's own origin:
git@github.com:SomeOrg/repo.git) →git@github.com:Boomatang/repo.gitssh://git@codeberg.org/someone/repo.git) →ssh://git@codeberg.org/Boomatang/repo.gitEdge cases
ls-remotefails or times out during GRAB_PATH walk → skip with warning