feat(git): GitClient.init for the new-project flow (T-487)

clide treats a git repo as the workspace, so creating a new project starts with
`git init`. Add GitClient.init — `git init -b <main>` in workDir, deterministic
default branch, idempotent on an existing repo. The first primitive of the
new-project flow (T-486); the create-dir + scaffold service and the
`clide project new` verb build on it next.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-28 08:19:10 +02:00
co-authored by Claude Opus 4.8
parent 6d7b96f115
commit b9fc720f97
5 changed files with 279 additions and 0 deletions
+12
View File
@@ -18,6 +18,18 @@ class GitClient {
final ToolchainView toolchain;
final Directory workDir;
/// Initialize a new git repository in [workDir] (T-487) — the backing of the
/// new-project flow, since clide treats a git repo as the workspace. The
/// directory must already exist. `-b <defaultBranch>` keeps the initial branch
/// deterministic rather than dependent on the user's git config. Idempotent:
/// `git init` on an existing repo is a no-op.
Future<void> init({String defaultBranch = 'main'}) async {
final r = await _run(['init', '-b', defaultBranch]);
if (r.exitCode != 0) {
throw GitException('git init failed', stderr: r.stderr.toString());
}
}
// -- queries --------------------------------------------------------------
Future<GitStatus> status() async {