fix(mkrep): stop the test suite creating real repos, and confirm implicit ones
Two related defects on the `$GIT_SERVER` auto-create path added in #150. The test suite was creating repositories on a live forge. mkrep resolves a server from `$GIT_SERVER` plus `$GITEA_URL`/`$GITEA_HOST`, and this repo doubles as a real ~/.config/fish where all of them are exported, so the six sections that call a bare `mkrep <dir>` took the auto-create branch and contacted the server. That is how an empty `rootiest/repo` came to exist on git.rootiest.dev on 2026-09-14 (since deleted). It also explains why those cases looked flaky rather than broken: standalone they passed, because the repo existed and mkrep linked instead of creating, while under run-tests.fish they failed with `Error: no available login` — a throwaway XDG_CONFIG_HOME leaves `tea` with no credentials. Passing for that reason is worse than failing. The suite now neutralizes all five variables once at setup, the same shadow-to-empty pattern already used per-section for --check-existing, whose comment flagged this exact hazard. Nothing depended on the ambient value: every section wanting a server sets its own `set -lx GIT_SERVER`, and one section asserts the opposite outright. mkrep itself now confirms before an implicit create. Creating a repository on a forge is the only outward-facing thing mkrep does, and on this path an exported variable is all it takes to reach it, so `mkrep foo` — which reads as purely local — would make a repo on a server without saying so. It asks first, defaulting to no; declining leaves the local repo with no remote and still exits 0. Provenance is what gates the prompt, not the resolved value: --server, --remote and --new-remote all state outright what they will do, so none of them prompts, and --yes skips the question. Where it cannot be asked (a script, a pipe, any non-interactive shell) creation is skipped rather than assumed, with a note on stderr naming the flags that would allow it. Nine new assertions cover the skip, its stderr note, --yes, and --server not prompting. The interactive read is verified by hand under a PTY, both answers, but is not in the suite: that needs a pseudo-terminal, and the answer parsing it guards is a single `string match`.
This commit is contained in:
+2282
-2702
File diff suppressed because it is too large
Load Diff
+20
-3
@@ -1275,7 +1275,7 @@ functions). They are active in all interactive sessions.
|
||||
[-c | --clean | --no-clean] [--strict] [-v | --verbose]
|
||||
[-s | --silent] [--template <path>] [--branch <name>]
|
||||
[--remote <url>] [--new-remote [<cmd>]] [--server <type>]
|
||||
[--check-existing] [--name <name>] [-h | --help] <dir>
|
||||
[--check-existing] [-y | --yes] [--name <name>] [-h | --help] <dir>
|
||||
|
||||
Creates a directory, cds into it, and git-inits it -- mkcd plus a git
|
||||
repo in one step. All three actions are on by default and each has a
|
||||
@@ -1323,6 +1323,19 @@ functions). They are active in all interactive sessions.
|
||||
requires a resolved server and is mutually exclusive with --remote
|
||||
and --new-remote.
|
||||
|
||||
Creating a repository on a live forge is the only outward-facing thing
|
||||
mkrep does, and on the $GIT_SERVER path an exported variable is all it
|
||||
takes to reach it -- so a plain mkrep call, which reads as purely
|
||||
local, would otherwise make a repo on a server without ever saying so.
|
||||
That case therefore asks for confirmation first, defaulting to no.
|
||||
Declining leaves the local repo in place with no remote and still
|
||||
exits 0. Linking an existing repo is not affected, and neither is an
|
||||
explicitly requested remote: --server, --remote and --new-remote all
|
||||
say outright what they are going to do, so none of them prompts. Pass
|
||||
--yes to skip the question. Where it cannot be asked -- a script, a
|
||||
pipe, any non-interactive shell -- creation is skipped rather than
|
||||
assumed, with a note on stderr naming the flags that would allow it.
|
||||
|
||||
Arguments:
|
||||
<dir> Directory to create and enter
|
||||
--cd, --no-cd Change into <dir> (default: --cd)
|
||||
@@ -1344,12 +1357,15 @@ functions). They are active in all interactive sessions.
|
||||
--server <type> Auto-create/link a remote on gitea, gitlab, or github
|
||||
--check-existing Report whether the repo exists on the resolved
|
||||
server; creates or links nothing
|
||||
-y, --yes Create the remote without confirming, on the
|
||||
$GIT_SERVER path that would otherwise ask
|
||||
--name <name> {name} substitution for --new-remote/--server
|
||||
(default: <dir>'s basename)
|
||||
-h, --help Show this help message
|
||||
|
||||
Exit Status:
|
||||
0 All requested steps completed
|
||||
0 All requested steps completed, or a $GIT_SERVER remote-create was
|
||||
declined at the prompt (the local repo is still set up)
|
||||
1 Bad arguments, or a step (mkdir, cd, git init, remote) failed
|
||||
|
||||
Example:
|
||||
@@ -1360,7 +1376,8 @@ functions). They are active in all interactive sessions.
|
||||
mkrep --new-remote ~/projects/foo
|
||||
set -gx GITEA_URL https://git.example.com
|
||||
set -gx GIT_SERVER gitea
|
||||
mkrep ~/projects/foo
|
||||
mkrep ~/projects/foo # asks before creating the remote
|
||||
mkrep --yes ~/projects/foo # creates it without asking
|
||||
mkrep --server gitlab --check-existing ~/projects/foo
|
||||
|
||||
Starting points for $MKREP_REMOTE_CMD, one per host CLI -- each assumes
|
||||
|
||||
Reference in New Issue
Block a user