feat(git): add --server/--check-existing to mkrep for gitea/gitlab/github #150

Merged
rootiest merged 3 commits from feat/mkrep-server-detection into main 2026-09-15 03:38:38 +00:00
Owner

Summary

  • mkrep gains --server <gitea|gitlab|github> and --check-existing, plus detection from $GIT_SERVER and $GITEA_URL/$GITEA_HOST/$GITLAB_URL/$GITLAB_HOST.
  • Type must come from --server or $GIT_SERVER; the _URL/_HOST vars only ever supply the base URL. This was a deliberate change from the original ask — see design note below.
  • Before creating a remote, mkrep checks via gh repo view / glab repo view / tea repos <owner>/<name> whether it already exists, and links instead of recreating it. --check-existing runs just that check and reports without touching remotes.
  • New helpers: _mkrep_default_remote_cmd, _mkrep_remote_url, _mkrep_repo_exists.
  • --remote/--new-remote still override everything, exactly as before.

Design note

The original spec had bare presence of $GITEA_URL/$GITEA_HOST/$GITLAB_URL/$GITLAB_HOST alone select the server type. Testing on this machine showed why that's unsafe: $GITEA_URL/$GITEA_HOST are already exported here for bd-pull's Gitea API calls, unrelated to mkrep. With the original design, every plain mkrep some-dir would have silently attempted to create a remote repo. Confirmed via AskUserQuestion to require $GIT_SERVER (or --server) to pick the type; the URL vars stay URL-only.

Test plan

  • fish tests/test-mkrep.fish — 58/58 pass, including new coverage for --server, --check-existing, env-var precedence, and conflict validation (gh/glab/tea calls stubbed via $PATH, no real network/auth needed)
  • fish tests/run-tests.fish — full suite, 719/719 pass
  • python3 docs/verify-manual.py — 84/84 pass
  • Manually try mkrep --server gitea some-dir against a real Gitea instance once a remote is available to verify against
## Summary - `mkrep` gains `--server <gitea|gitlab|github>` and `--check-existing`, plus detection from `$GIT_SERVER` and `$GITEA_URL`/`$GITEA_HOST`/`$GITLAB_URL`/`$GITLAB_HOST`. - Type must come from `--server` or `$GIT_SERVER`; the `_URL`/`_HOST` vars only ever supply the base URL. This was a deliberate change from the original ask — see design note below. - Before creating a remote, mkrep checks via `gh repo view` / `glab repo view` / `tea repos <owner>/<name>` whether it already exists, and links instead of recreating it. `--check-existing` runs just that check and reports without touching remotes. - New helpers: `_mkrep_default_remote_cmd`, `_mkrep_remote_url`, `_mkrep_repo_exists`. - `--remote`/`--new-remote` still override everything, exactly as before. ### Design note The original spec had bare presence of `$GITEA_URL`/`$GITEA_HOST`/`$GITLAB_URL`/`$GITLAB_HOST` alone select the server type. Testing on this machine showed why that's unsafe: `$GITEA_URL`/`$GITEA_HOST` are already exported here for `bd-pull`'s Gitea API calls, unrelated to `mkrep`. With the original design, every plain `mkrep some-dir` would have silently attempted to create a remote repo. Confirmed via `AskUserQuestion` to require `$GIT_SERVER` (or `--server`) to pick the type; the URL vars stay URL-only. ## Test plan - [x] `fish tests/test-mkrep.fish` — 58/58 pass, including new coverage for `--server`, `--check-existing`, env-var precedence, and conflict validation (gh/glab/tea calls stubbed via `$PATH`, no real network/auth needed) - [x] `fish tests/run-tests.fish` — full suite, 719/719 pass - [x] `python3 docs/verify-manual.py` — 84/84 pass - [x] Manually try `mkrep --server gitea some-dir` against a real Gitea instance once a remote is available to verify against
rootiest added the Kind/FeatureArea/Functions labels 2026-09-15 01:07:19 +00:00
rootiest added 1 commit 2026-09-15 01:07:20 +00:00
mkrep can now pick a git host from --server, $GIT_SERVER, and
$GITEA_URL/$GITEA_HOST/$GITLAB_URL/$GITLAB_HOST (base URL only -- type
must come from --server/$GIT_SERVER, so setting those URL vars for an
unrelated tool can't silently turn a plain mkrep call into a
remote-creating one). Before creating anything it checks via
gh/glab/tea whether the repo already exists and links instead of
recreating it; --check-existing runs just that check and reports
without touching remotes.
rootiest added 1 commit 2026-09-15 03:11:17 +00:00
$GITEA_HOST/$GITLAB_HOST are bare hostnames (git.example.com); only
$GITEA_URL/$GITLAB_URL are expected to carry a scheme. mkrep was using
_HOST values as-is, producing a schemeless clone URL when only the
_HOST var was set.
rootiest added 1 commit 2026-09-15 03:22:57 +00:00
mkrep only ever runs git init, never a commit, so a freshly created
repo has no HEAD yet. The gitea/gitlab default templates chained
`git push -u origin HEAD` unconditionally after linking the remote,
which fails immediately regardless of the remote ("src refspec HEAD
does not match any") -- reproduced by a real user hitting it on the
first mkrep --server call. Guard the push on HEAD actually resolving
to a commit; skipping it is the correct outcome (nothing to push yet),
and a real push failure once a commit exists still propagates.
rootiest merged commit 35b2d0a16c into main 2026-09-15 03:38:38 +00:00
rootiest deleted branch feat/mkrep-server-detection 2026-09-15 03:38:38 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rootiest/fish-config#150