gitmux 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gitmux/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ """gitmux - Manage multiple git repositories with ease."""
2
+
3
+ __version__ = "0.1.0"
gitmux/cli.py ADDED
@@ -0,0 +1,535 @@
1
+ """gitmux CLI entry point."""
2
+
3
+ from pathlib import Path
4
+
5
+ import typer
6
+ from rich import print as rprint
7
+ from rich.console import Console
8
+ from rich.table import Table
9
+
10
+ from gitmux import __version__
11
+ from gitmux.config import DEFAULT_CONFIG_PATH, find_config, load_config, save_config, validate_config
12
+ from gitmux.models import GitmuxConfig, GroupConfig, RepoConfig
13
+
14
+ app = typer.Typer(name="gitmux", help="Manage multiple git repositories with ease.", no_args_is_help=True)
15
+ group_app = typer.Typer(name="group", help="Manage repository groups.")
16
+ app.add_typer(group_app, name="group")
17
+
18
+ console = Console()
19
+
20
+ CONFIG_OPT = typer.Option(None, "--config", "-c", help="Path to config file.")
21
+
22
+
23
+ def _load(config_path: Path | None) -> GitmuxConfig:
24
+ path = Path(config_path) if config_path else find_config()
25
+ if not path.exists():
26
+ rprint(f"[red]Config not found: {path}[/]\nRun [bold]gitmux init[/] first.")
27
+ raise typer.Exit(1)
28
+ cfg = load_config(path)
29
+ errors = validate_config(cfg)
30
+ if errors:
31
+ for e in errors:
32
+ rprint(f"[red]Config error:[/] {e}")
33
+ raise typer.Exit(1)
34
+ return cfg
35
+
36
+
37
+ def _save(config: GitmuxConfig, config_path: Path | None) -> None:
38
+ save_config(config, Path(config_path) if config_path else find_config())
39
+
40
+
41
+ def version_callback(value: bool) -> None:
42
+ if value:
43
+ rprint(f"gitmux [bold green]{__version__}[/]")
44
+ raise typer.Exit()
45
+
46
+
47
+ @app.callback()
48
+ def main(
49
+ version: bool | None = typer.Option(
50
+ None,
51
+ "--version",
52
+ "-v",
53
+ callback=version_callback,
54
+ is_eager=True,
55
+ help="Show version and exit.",
56
+ ),
57
+ ) -> None:
58
+ """Manage multiple git repositories with ease."""
59
+
60
+
61
+ @app.command()
62
+ def init(
63
+ workspace: str = typer.Option("~/projects", prompt="Workspace directory"),
64
+ global_: bool = typer.Option(False, "--global", "-g", help="Create global config at ~/.gitmux.yaml"),
65
+ ) -> None:
66
+ """Initialize a new .gitmux.yaml configuration file."""
67
+ path = DEFAULT_CONFIG_PATH if global_ else Path.cwd() / ".gitmux.yaml"
68
+ if path.exists():
69
+ overwrite = typer.confirm(f"{path} already exists. Overwrite?", default=False)
70
+ if not overwrite:
71
+ raise typer.Exit()
72
+ cfg = GitmuxConfig(workspace=workspace)
73
+ save_config(cfg, path)
74
+ rprint(f"[green]Config created:[/] {path}")
75
+
76
+
77
+ @app.command()
78
+ def add(
79
+ url: str = typer.Argument(..., help="Git repository URL."),
80
+ group: str = typer.Option("default", "--group", "-g", help="Group to add the repo to."),
81
+ name: str | None = typer.Option(None, "--name", "-n", help="Repo name (default: derived from URL)."),
82
+ template: str | None = typer.Option(None, "--template", "-t", help="Hook template to use."),
83
+ config: Path | None = CONFIG_OPT,
84
+ ) -> None:
85
+ """Add a repository to the configuration."""
86
+ cfg = _load(config)
87
+ repo_name = name or url.rstrip("/").split("/")[-1].removesuffix(".git")
88
+ if cfg.find_repo(repo_name):
89
+ rprint(f"[red]Repo '{repo_name}' already exists.[/]")
90
+ raise typer.Exit(1)
91
+
92
+ grp = cfg.find_group(group)
93
+ if not grp:
94
+ grp = GroupConfig(name=group)
95
+ cfg.groups.append(grp)
96
+ rprint(f"[dim]Created group:[/] {group}")
97
+
98
+ if template and template not in cfg.templates:
99
+ rprint(f"[red]Template '{template}' not found.[/]")
100
+ raise typer.Exit(1)
101
+
102
+ repo = RepoConfig(name=repo_name, url=url, template=template)
103
+ grp.repos.append(repo)
104
+ _save(cfg, config)
105
+ rprint(f"[green]Added[/] {repo_name} to group '{group}'")
106
+
107
+
108
+ @app.command()
109
+ def remove(
110
+ name: str = typer.Argument(..., help="Repository name to remove."),
111
+ config: Path | None = CONFIG_OPT,
112
+ ) -> None:
113
+ """Remove a repository from the configuration."""
114
+ cfg = _load(config)
115
+ result = cfg.find_repo(name)
116
+ if not result:
117
+ rprint(f"[red]Repo '{name}' not found.[/]")
118
+ raise typer.Exit(1)
119
+ repo, grp = result
120
+ grp.repos.remove(repo)
121
+ _save(cfg, config)
122
+ rprint(f"[green]Removed[/] {name} from group '{grp.name}'")
123
+
124
+
125
+ @app.command(name="list")
126
+ def list_repos(
127
+ group: str | None = typer.Option(None, "--group", "-g", help="Filter by group."),
128
+ config: Path | None = CONFIG_OPT,
129
+ ) -> None:
130
+ """List all configured repositories."""
131
+ cfg = _load(config)
132
+ table = Table(title="Repositories")
133
+ table.add_column("Group", style="cyan")
134
+ table.add_column("Name", style="bold")
135
+ table.add_column("URL")
136
+ table.add_column("Path")
137
+ table.add_column("Template", style="dim")
138
+
139
+ for grp in cfg.groups:
140
+ if group and grp.name != group:
141
+ continue
142
+ for repo in grp.repos:
143
+ path = str(cfg.get_repo_path(repo, grp))
144
+ table.add_row(grp.name, repo.name, repo.url, path, repo.template or "")
145
+
146
+ console.print(table)
147
+
148
+
149
+ # --- Group subcommands ---
150
+
151
+
152
+ DEFAULT_GROUP = "default"
153
+
154
+
155
+ def _get_repos(cfg: GitmuxConfig, target: str | None, all_: bool, group: str | None = None) -> list[tuple]:
156
+ """Resolve target repos.
157
+
158
+ - target = "name" → find repo in default group
159
+ - target = "group/name" → find repo in specified group
160
+ - --group = operate on entire group
161
+ - --all = all repos
162
+ - nothing = error
163
+ """
164
+ if target:
165
+ if "/" in target:
166
+ group_name, repo_name = target.split("/", 1)
167
+ else:
168
+ group_name, repo_name = DEFAULT_GROUP, target
169
+ grp = cfg.find_group(group_name)
170
+ if not grp:
171
+ rprint(f"[red]Group '{group_name}' not found.[/]")
172
+ raise typer.Exit(1)
173
+ for repo in grp.repos:
174
+ if repo.name == repo_name:
175
+ return [(repo, grp)]
176
+ rprint(f"[red]Repo '{repo_name}' not found in group '{group_name}'.[/]")
177
+ raise typer.Exit(1)
178
+ if group:
179
+ grp = cfg.find_group(group)
180
+ if not grp:
181
+ rprint(f"[red]Group '{group}' not found.[/]")
182
+ raise typer.Exit(1)
183
+ return [(r, grp) for r in grp.repos]
184
+ if all_:
185
+ return cfg.all_repos()
186
+ rprint("[red]Please specify a repo, --group, or --all.[/]")
187
+ raise typer.Exit(1)
188
+
189
+
190
+ @app.command()
191
+ def clone(
192
+ target: str | None = typer.Argument(None, help="Repo name or group/repo."),
193
+ group: str | None = typer.Option(None, "--group", "-g", help="Operate on entire group."),
194
+ all_: bool = typer.Option(False, "--all", "-a", help="Operate on all repositories."),
195
+ parallel: bool = typer.Option(False, "--parallel", "-p", help="Run in parallel."),
196
+ config: Path | None = CONFIG_OPT,
197
+ ) -> None:
198
+ """Clone repositories that haven't been cloned yet."""
199
+ from gitmux import git_ops
200
+ from gitmux.executor import run_parallel, run_serial
201
+
202
+ cfg = _load(config)
203
+ repos = _get_repos(cfg, target, all_, group)
204
+
205
+ def do_clone(repo, grp, c):
206
+ path = c.get_repo_path(repo, grp)
207
+ if path.exists():
208
+ return git_ops.GitResult(True, "Already cloned", "skip")
209
+ return git_ops.clone(repo.url, path)
210
+
211
+ (run_parallel if parallel else run_serial)(cfg, repos, do_clone, "Clone")
212
+
213
+
214
+ @app.command()
215
+ def fetch(
216
+ target: str | None = typer.Argument(None, help="Repo name or group/repo."),
217
+ group: str | None = typer.Option(None, "--group", "-g", help="Operate on entire group."),
218
+ all_: bool = typer.Option(False, "--all", "-a", help="Operate on all repositories."),
219
+ parallel: bool = typer.Option(False, "--parallel", "-p", help="Run in parallel."),
220
+ show_branches: bool = typer.Option(False, "--branches", help="Show remote branches after fetch."),
221
+ config: Path | None = CONFIG_OPT,
222
+ ) -> None:
223
+ """Fetch latest remote data for repositories."""
224
+ from gitmux import git_ops
225
+ from gitmux.executor import run_parallel as run_par
226
+ from gitmux.executor import run_serial
227
+
228
+ cfg = _load(config)
229
+ repos = _get_repos(cfg, target, all_, group)
230
+
231
+ def do_fetch(repo, grp, c):
232
+ path = c.get_repo_path(repo, grp)
233
+ if not path.exists():
234
+ return git_ops.GitResult(False, f"Not cloned: {path}", "git fetch")
235
+ result = git_ops.fetch(path)
236
+ if result.success and show_branches:
237
+ branches = git_ops.list_remote_branches(path, "*")
238
+ result = git_ops.GitResult(True, "\n".join(branches) if branches else "(no remote branches)", result.command)
239
+ return result
240
+
241
+ (run_par if parallel else run_serial)(cfg, repos, do_fetch, "Fetch")
242
+
243
+
244
+ @app.command()
245
+ def pull(
246
+ target: str | None = typer.Argument(None, help="Repo name or group/repo."),
247
+ group: str | None = typer.Option(None, "--group", "-g", help="Operate on entire group."),
248
+ all_: bool = typer.Option(False, "--all", "-a", help="Operate on all repositories."),
249
+ branch: str | None = typer.Option(None, "--branch", "-b", help="Branch alias, e.g. 'dev', 'prod:latest', 'prod:~20260520', 'prod:20260524'."),
250
+ parallel: bool = typer.Option(False, "--parallel", "-p", help="Run in parallel."),
251
+ config: Path | None = CONFIG_OPT,
252
+ ) -> None:
253
+ """Pull latest changes for repositories."""
254
+ from gitmux import git_ops
255
+ from gitmux.executor import run_parallel as run_par
256
+ from gitmux.executor import run_serial
257
+
258
+ cfg = _load(config)
259
+ repos = _get_repos(cfg, target, all_, group)
260
+
261
+ # Parse --branch flag: "name" or "name:value"
262
+ branch_alias: str | None = None
263
+ branch_value: str | None = None
264
+ if branch:
265
+ if ":" in branch:
266
+ branch_alias, branch_value = branch.split(":", 1)
267
+ else:
268
+ branch_alias = branch
269
+
270
+ def do_pull(repo, grp, c):
271
+ path = c.get_repo_path(repo, grp)
272
+ if not path.exists():
273
+ return git_ops.GitResult(False, f"Not cloned: {path}", "git pull")
274
+
275
+ if not branch_alias:
276
+ return git_ops.pull(path)
277
+
278
+ # Resolve branch from config
279
+ if branch_alias not in repo.branches:
280
+ return git_ops.GitResult(
281
+ False, f"Branch alias '{branch_alias}' not configured", "branch resolve"
282
+ )
283
+
284
+ pattern = repo.branches[branch_alias]
285
+ is_pattern = "*" in pattern
286
+
287
+ if branch_value is None:
288
+ # gitmux pull --branch dev → must be fixed
289
+ if is_pattern:
290
+ return git_ops.GitResult(
291
+ False,
292
+ f"'{branch_alias}' is a pattern ({pattern}), use --branch {branch_alias}:latest or --branch {branch_alias}:<value>",
293
+ "branch resolve",
294
+ )
295
+ target = pattern
296
+ elif branch_value == "latest":
297
+ # gitmux pull --branch prod:latest → must be pattern
298
+ if not is_pattern:
299
+ return git_ops.GitResult(
300
+ False,
301
+ f"'{branch_alias}' is a fixed branch ({pattern}), use --branch {branch_alias} directly",
302
+ "branch resolve",
303
+ )
304
+ fetch_result = git_ops.fetch(path)
305
+ if not fetch_result.success:
306
+ return fetch_result
307
+ matches = git_ops.list_remote_branches(path, pattern)
308
+ if not matches:
309
+ return git_ops.GitResult(False, f"No remote branch matching '{pattern}'", "branch resolve")
310
+ target = matches[0] # sorted by committerdate, newest first
311
+ elif branch_value.startswith("~"):
312
+ # gitmux pull --branch prod:~20260520 → find latest branch with date <= 20260520
313
+ if not is_pattern:
314
+ return git_ops.GitResult(
315
+ False,
316
+ f"'{branch_alias}' is a fixed branch ({pattern}), use --branch {branch_alias} directly",
317
+ "branch resolve",
318
+ )
319
+ date_str = branch_value[1:]
320
+ # Normalize to 6-digit date for comparison (YYMMDD)
321
+ if len(date_str) == 8:
322
+ date_str = date_str[2:]
323
+ fetch_result = git_ops.fetch(path)
324
+ if not fetch_result.success:
325
+ return fetch_result
326
+ matches = git_ops.list_remote_branches(path, pattern)
327
+ if not matches:
328
+ return git_ops.GitResult(False, f"No remote branch matching '{pattern}'", "branch resolve")
329
+ # Extract date from branch names and find <= date_str
330
+ import re as _re
331
+ candidates = []
332
+ for m in matches:
333
+ found = _re.search(r"(\d{6})", m)
334
+ if found and found.group(1) <= date_str:
335
+ candidates.append(m)
336
+ if not candidates:
337
+ return git_ops.GitResult(
338
+ False,
339
+ f"No branch matching '{pattern}' with date <= {date_str} (found: {matches[:5]})",
340
+ "branch resolve",
341
+ )
342
+ target = candidates[0] # already sorted by committerdate newest first
343
+ else:
344
+ # gitmux pull --branch prod:20260524 → replace * with value
345
+ if not is_pattern:
346
+ return git_ops.GitResult(
347
+ False,
348
+ f"'{branch_alias}' is a fixed branch ({pattern}), use --branch {branch_alias} directly",
349
+ "branch resolve",
350
+ )
351
+ target = pattern.replace("*", branch_value)
352
+
353
+ # Fetch if not already done
354
+ if branch_value != "latest":
355
+ fetch_result = git_ops.fetch(path)
356
+ if not fetch_result.success:
357
+ return fetch_result
358
+
359
+ # Checkout and pull
360
+ checkout_result = git_ops.checkout(path, target)
361
+ if not checkout_result.success:
362
+ return git_ops.GitResult(False, f"Checkout failed: {checkout_result.output}", f"git checkout {target}")
363
+
364
+ pull_result = git_ops.pull(path)
365
+ msg = f"[{target}] {pull_result.output}"
366
+ return git_ops.GitResult(pull_result.success, msg, pull_result.command)
367
+
368
+ (run_par if parallel else run_serial)(cfg, repos, do_pull, "Pull")
369
+
370
+
371
+
372
+ @app.command()
373
+ def push(
374
+ target: str | None = typer.Argument(None, help="Repo name or group/repo."),
375
+ group: str | None = typer.Option(None, "--group", "-g", help="Operate on entire group."),
376
+ all_: bool = typer.Option(False, "--all", "-a", help="Operate on all repositories."),
377
+ parallel: bool = typer.Option(False, "--parallel", "-p", help="Run in parallel."),
378
+ config: Path | None = CONFIG_OPT,
379
+ ) -> None:
380
+ """Push local commits for repositories."""
381
+ from gitmux import git_ops
382
+ from gitmux.executor import run_parallel, run_serial
383
+
384
+ cfg = _load(config)
385
+ repos = _get_repos(cfg, target, all_, group)
386
+
387
+ def do_push(repo, grp, c):
388
+ path = c.get_repo_path(repo, grp)
389
+ if not path.exists():
390
+ return git_ops.GitResult(False, f"Not cloned: {path}", "git push")
391
+ return git_ops.push(path)
392
+
393
+ (run_parallel if parallel else run_serial)(cfg, repos, do_push, "Push")
394
+
395
+
396
+ @app.command(name="exec")
397
+ def exec_cmd(
398
+ command: str = typer.Argument(..., help="Shell command to execute in each repo."),
399
+ target: str | None = typer.Option(None, "--target", "-t", help="Repo name or group/repo."),
400
+ group: str | None = typer.Option(None, "--group", "-g", help="Operate on entire group."),
401
+ all_: bool = typer.Option(False, "--all", "-a", help="Operate on all repositories."),
402
+ parallel: bool = typer.Option(False, "--parallel", "-p", help="Run in parallel."),
403
+ config: Path | None = CONFIG_OPT,
404
+ ) -> None:
405
+ """Execute an arbitrary command in each repository directory."""
406
+ import subprocess
407
+
408
+ from gitmux.executor import run_parallel, run_serial
409
+ from gitmux.git_ops import GitResult
410
+
411
+ cfg = _load(config)
412
+ repos = _get_repos(cfg, target, all_, group)
413
+
414
+ def do_exec(repo, grp, c):
415
+ path = c.get_repo_path(repo, grp)
416
+ if not path.exists():
417
+ return GitResult(False, f"Directory not found: {path}", command)
418
+ try:
419
+ result = subprocess.run(
420
+ command,
421
+ shell=True,
422
+ cwd=path,
423
+ capture_output=True,
424
+ text=True,
425
+ timeout=120,
426
+ )
427
+ output = (result.stdout + result.stderr).strip()
428
+ return GitResult(result.returncode == 0, output, command)
429
+ except subprocess.TimeoutExpired:
430
+ return GitResult(False, "Command timed out (120s)", command)
431
+
432
+ (run_parallel if parallel else run_serial)(cfg, repos, do_exec, "Exec")
433
+
434
+
435
+ @app.command()
436
+ def status(
437
+ target: str | None = typer.Argument(None, help="Repo name or group/repo. Shows all if omitted."),
438
+ group: str | None = typer.Option(None, "--group", "-g", help="Filter by group."),
439
+ config: Path | None = CONFIG_OPT,
440
+ ) -> None:
441
+ """Show status overview of all repositories."""
442
+ from gitmux import git_ops
443
+
444
+ cfg = _load(config)
445
+ repos = _get_repos(cfg, target, all_=not target and not group, group=group)
446
+
447
+ table = Table(title="Repository Status")
448
+ table.add_column("Group", style="cyan")
449
+ table.add_column("Name", style="bold")
450
+ table.add_column("Branch")
451
+ table.add_column("Status")
452
+ table.add_column("Ahead/Behind")
453
+ table.add_column("Last Commit", style="dim", max_width=40)
454
+
455
+ for repo, grp in repos:
456
+ path = cfg.get_repo_path(repo, grp)
457
+ if not path.exists():
458
+ table.add_row(grp.name, repo.name, "-", "[red]Not cloned[/]", "-", "-")
459
+ continue
460
+
461
+ branch_result = git_ops.current_branch(path)
462
+ branch = branch_result.output if branch_result.success else "?"
463
+
464
+ status_result = git_ops.status(path)
465
+ if status_result.success:
466
+ state = "[green]Clean[/]" if not status_result.output else "[yellow]Dirty[/]"
467
+ else:
468
+ state = "[red]Error[/]"
469
+
470
+ ahead, behind = git_ops.ahead_behind(path)
471
+ ab = ""
472
+ if ahead:
473
+ ab += f"[green]↑{ahead}[/]"
474
+ if behind:
475
+ ab += f"[red]↓{behind}[/]"
476
+ if not ab:
477
+ ab = "[dim]—[/]"
478
+
479
+ commit = git_ops.last_commit(path)
480
+ table.add_row(grp.name, repo.name, branch, state, ab, commit)
481
+
482
+ console.print(table)
483
+
484
+
485
+ # --- Group subcommands ---
486
+
487
+
488
+ @group_app.command(name="list")
489
+ def group_list(config: Path | None = CONFIG_OPT) -> None:
490
+ """List all groups."""
491
+ cfg = _load(config)
492
+ if not cfg.groups:
493
+ rprint("[dim]No groups configured.[/]")
494
+ return
495
+ table = Table(title="Groups")
496
+ table.add_column("Name", style="cyan bold")
497
+ table.add_column("Repos", justify="right")
498
+ for grp in cfg.groups:
499
+ table.add_row(grp.name, str(len(grp.repos)))
500
+ console.print(table)
501
+
502
+
503
+ @group_app.command(name="create")
504
+ def group_create(
505
+ name: str = typer.Argument(..., help="Group name."),
506
+ config: Path | None = CONFIG_OPT,
507
+ ) -> None:
508
+ """Create a new group."""
509
+ cfg = _load(config)
510
+ if cfg.find_group(name):
511
+ rprint(f"[red]Group '{name}' already exists.[/]")
512
+ raise typer.Exit(1)
513
+ cfg.groups.append(GroupConfig(name=name))
514
+ _save(cfg, config)
515
+ rprint(f"[green]Created group:[/] {name}")
516
+
517
+
518
+ @group_app.command(name="remove")
519
+ def group_remove(
520
+ name: str = typer.Argument(..., help="Group name."),
521
+ force: bool = typer.Option(False, "--force", "-f", help="Remove even if group has repos."),
522
+ config: Path | None = CONFIG_OPT,
523
+ ) -> None:
524
+ """Remove a group."""
525
+ cfg = _load(config)
526
+ grp = cfg.find_group(name)
527
+ if not grp:
528
+ rprint(f"[red]Group '{name}' not found.[/]")
529
+ raise typer.Exit(1)
530
+ if grp.repos and not force:
531
+ rprint(f"[red]Group '{name}' has {len(grp.repos)} repos.[/] Use --force to remove.")
532
+ raise typer.Exit(1)
533
+ cfg.groups.remove(grp)
534
+ _save(cfg, config)
535
+ rprint(f"[green]Removed group:[/] {name}")
gitmux/config.py ADDED
@@ -0,0 +1,131 @@
1
+ """Configuration loading, saving, and validation."""
2
+
3
+ from pathlib import Path
4
+
5
+ import yaml
6
+
7
+ from gitmux.models import GitmuxConfig, GroupConfig, HookConfig, RepoConfig
8
+
9
+ DEFAULT_CONFIG_PATH = Path.home() / ".gitmux.yaml"
10
+ LOCAL_CONFIG_NAME = ".gitmux.yaml"
11
+
12
+
13
+ def find_config() -> Path:
14
+ """Find config file: current dir → home dir."""
15
+ local = Path.cwd() / LOCAL_CONFIG_NAME
16
+ if local.exists():
17
+ return local
18
+ return DEFAULT_CONFIG_PATH
19
+
20
+
21
+ def _parse_hooks(data: dict | None) -> HookConfig:
22
+ if not data:
23
+ return HookConfig()
24
+ return HookConfig(
25
+ pre_clone=data.get("pre_clone", []),
26
+ post_clone=data.get("post_clone", []),
27
+ pre_pull=data.get("pre_pull", []),
28
+ post_pull=data.get("post_pull", []),
29
+ pre_push=data.get("pre_push", []),
30
+ post_push=data.get("post_push", []),
31
+ )
32
+
33
+
34
+ def _parse_repo(data: dict) -> RepoConfig:
35
+ return RepoConfig(
36
+ name=data["name"],
37
+ url=data["url"],
38
+ path=data.get("path"),
39
+ template=data.get("template"),
40
+ hooks=_parse_hooks(data.get("hooks")),
41
+ branches=data.get("branches") or {},
42
+ )
43
+
44
+
45
+ def load_config(path: Path | None = None) -> GitmuxConfig:
46
+ """Load and parse gitmux config from YAML file."""
47
+ path = path or DEFAULT_CONFIG_PATH
48
+ if not path.exists():
49
+ return GitmuxConfig()
50
+
51
+ with open(path, encoding="utf-8") as f:
52
+ data = yaml.safe_load(f) or {}
53
+
54
+ templates = {}
55
+ for name, hook_data in (data.get("templates") or {}).items():
56
+ templates[name] = _parse_hooks(hook_data)
57
+
58
+ groups = []
59
+ for group_name, group_data in (data.get("groups") or {}).items():
60
+ repos = [_parse_repo(r) for r in (group_data.get("repos") or [])]
61
+ groups.append(GroupConfig(name=group_name, repos=repos))
62
+
63
+ return GitmuxConfig(
64
+ workspace=data.get("workspace", "~/projects"),
65
+ templates=templates,
66
+ groups=groups,
67
+ )
68
+
69
+
70
+ def _hooks_to_dict(hooks: HookConfig) -> dict | None:
71
+ d = {}
72
+ for key in ("pre_clone", "post_clone", "pre_pull", "post_pull", "pre_push", "post_push"):
73
+ val = getattr(hooks, key)
74
+ if val:
75
+ d[key] = val
76
+ return d or None
77
+
78
+
79
+ def save_config(config: GitmuxConfig, path: Path | None = None) -> None:
80
+ """Save gitmux config to YAML file."""
81
+ path = path or DEFAULT_CONFIG_PATH
82
+ data: dict = {"workspace": config.workspace}
83
+
84
+ if config.templates:
85
+ data["templates"] = {}
86
+ for name, hooks in config.templates.items():
87
+ data["templates"][name] = _hooks_to_dict(hooks) or {}
88
+
89
+ if config.groups:
90
+ data["groups"] = {}
91
+ for group in config.groups:
92
+ repos = []
93
+ for repo in group.repos:
94
+ r: dict = {"name": repo.name, "url": repo.url}
95
+ if repo.path:
96
+ r["path"] = repo.path
97
+ if repo.template:
98
+ r["template"] = repo.template
99
+ hooks_dict = _hooks_to_dict(repo.hooks)
100
+ if hooks_dict:
101
+ r["hooks"] = hooks_dict
102
+ if repo.branches:
103
+ r["branches"] = repo.branches
104
+ repos.append(r)
105
+ data["groups"][group.name] = {"repos": repos}
106
+
107
+ path.parent.mkdir(parents=True, exist_ok=True)
108
+ with open(path, "w", encoding="utf-8") as f:
109
+ yaml.dump(data, f, default_flow_style=False, allow_unicode=True, sort_keys=False)
110
+
111
+
112
+ def validate_config(config: GitmuxConfig) -> list[str]:
113
+ """Validate config, return list of error messages."""
114
+ errors = []
115
+ repo_names: set[str] = set()
116
+ group_names: set[str] = set()
117
+
118
+ for group in config.groups:
119
+ if group.name in group_names:
120
+ errors.append(f"Duplicate group name: {group.name}")
121
+ group_names.add(group.name)
122
+
123
+ for repo in group.repos:
124
+ if repo.name in repo_names:
125
+ errors.append(f"Duplicate repo name: {repo.name}")
126
+ repo_names.add(repo.name)
127
+
128
+ if repo.template and repo.template not in config.templates:
129
+ errors.append(f"Repo '{repo.name}' references unknown template: {repo.template}")
130
+
131
+ return errors
gitmux/executor.py ADDED
@@ -0,0 +1,125 @@
1
+ """Execution engine for git operations (serial and parallel)."""
2
+
3
+ from collections.abc import Callable
4
+ from concurrent.futures import ThreadPoolExecutor, as_completed
5
+ from dataclasses import dataclass
6
+
7
+ from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn
8
+
9
+ from gitmux.git_ops import GitResult
10
+ from gitmux.hooks import resolve_hooks, run_hooks
11
+ from gitmux.models import GitmuxConfig, GroupConfig, RepoConfig
12
+ from gitmux.output import console, print_error, print_header, print_step, print_success
13
+
14
+
15
+ @dataclass
16
+ class RepoResult:
17
+ repo_name: str
18
+ success: bool
19
+ message: str
20
+
21
+
22
+ def _execute_one(
23
+ repo: RepoConfig,
24
+ group: GroupConfig,
25
+ config: GitmuxConfig,
26
+ operation: Callable[[RepoConfig, GroupConfig, GitmuxConfig], GitResult],
27
+ op_name: str,
28
+ ) -> RepoResult:
29
+ """Execute pre-hook → operation → post-hook for a single repo."""
30
+ path = config.get_repo_path(repo, group)
31
+ hooks = resolve_hooks(repo, config)
32
+ pre_cmds = getattr(hooks, f"pre_{op_name.lower()}", [])
33
+ post_cmds = getattr(hooks, f"post_{op_name.lower()}", [])
34
+
35
+ # Pre-hook
36
+ if pre_cmds and path.exists():
37
+ hook_result = run_hooks(pre_cmds, path, label=f"pre-{op_name.lower()}")
38
+ if not hook_result.success:
39
+ return RepoResult(repo.name, False, f"Pre-hook failed: {hook_result.failed_command}\n{hook_result.output}")
40
+
41
+ # Git operation
42
+ git_result = operation(repo, group, config)
43
+ if not git_result.success:
44
+ return RepoResult(repo.name, False, git_result.output)
45
+
46
+ # Post-hook
47
+ if post_cmds and path.exists():
48
+ hook_result = run_hooks(post_cmds, path, label=f"post-{op_name.lower()}")
49
+ if not hook_result.success:
50
+ return RepoResult(repo.name, False, f"Post-hook failed: {hook_result.failed_command}\n{hook_result.output}")
51
+
52
+ return RepoResult(repo.name, True, git_result.output)
53
+
54
+
55
+ def run_serial(
56
+ config: GitmuxConfig,
57
+ repos: list[tuple[RepoConfig, GroupConfig]],
58
+ operation: Callable[[RepoConfig, GroupConfig, GitmuxConfig], GitResult],
59
+ op_name: str,
60
+ ) -> list[RepoResult]:
61
+ """Execute an operation on repos serially with real-time output."""
62
+ print_header(op_name)
63
+ results: list[RepoResult] = []
64
+
65
+ for repo, group in repos:
66
+ print_step(repo.name, op_name.lower())
67
+ result = _execute_one(repo, group, config, operation, op_name)
68
+ if result.success:
69
+ print_success(repo.name, result.message)
70
+ else:
71
+ print_error(repo.name, result.message)
72
+ results.append(result)
73
+
74
+ _print_summary(results)
75
+ return results
76
+
77
+
78
+ def run_parallel(
79
+ config: GitmuxConfig,
80
+ repos: list[tuple[RepoConfig, GroupConfig]],
81
+ operation: Callable[[RepoConfig, GroupConfig, GitmuxConfig], GitResult],
82
+ op_name: str,
83
+ max_workers: int = 4,
84
+ ) -> list[RepoResult]:
85
+ """Execute an operation on repos in parallel with progress bar."""
86
+ results: list[RepoResult] = []
87
+
88
+ with Progress(
89
+ SpinnerColumn(),
90
+ TextColumn("[bold]{task.description}"),
91
+ BarColumn(),
92
+ TextColumn("[progress.percentage]{task.percentage:>3.0f}%"),
93
+ console=console,
94
+ ) as progress:
95
+ task = progress.add_task(f"{op_name}...", total=len(repos))
96
+
97
+ with ThreadPoolExecutor(max_workers=max_workers) as executor:
98
+ futures = {
99
+ executor.submit(_execute_one, repo, group, config, operation, op_name): repo.name
100
+ for repo, group in repos
101
+ }
102
+ for future in as_completed(futures):
103
+ result = future.result()
104
+ results.append(result)
105
+ progress.advance(task)
106
+
107
+ # Print detailed results
108
+ console.print()
109
+ for r in results:
110
+ if r.success:
111
+ console.print(f" [bold cyan]{r.repo_name}[/] [green]✓[/]")
112
+ else:
113
+ console.print(f" [bold cyan]{r.repo_name}[/] [red]✗[/] {r.message}")
114
+
115
+ _print_summary(results)
116
+ return results
117
+
118
+
119
+ def _print_summary(results: list[RepoResult]) -> None:
120
+ success_count = sum(1 for r in results if r.success)
121
+ fail_count = len(results) - success_count
122
+ summary = f"\n[green]{success_count} succeeded[/]"
123
+ if fail_count:
124
+ summary += f", [red]{fail_count} failed[/]"
125
+ console.print(summary)
gitmux/git_ops.py ADDED
@@ -0,0 +1,103 @@
1
+ """Git operation wrappers using subprocess."""
2
+
3
+ import subprocess
4
+ from dataclasses import dataclass
5
+ from pathlib import Path
6
+
7
+
8
+ @dataclass
9
+ class GitResult:
10
+ success: bool
11
+ output: str
12
+ command: str
13
+
14
+
15
+ def _run(args: list[str], cwd: Path | None = None) -> GitResult:
16
+ cmd_str = " ".join(args)
17
+ try:
18
+ result = subprocess.run(
19
+ args,
20
+ cwd=cwd,
21
+ capture_output=True,
22
+ text=True,
23
+ encoding="utf-8",
24
+ errors="replace",
25
+ timeout=300,
26
+ )
27
+ output = ((result.stdout or "") + (result.stderr or "")).strip()
28
+ return GitResult(success=result.returncode == 0, output=output, command=cmd_str)
29
+ except subprocess.TimeoutExpired:
30
+ return GitResult(success=False, output="Command timed out (300s)", command=cmd_str)
31
+ except FileNotFoundError:
32
+ return GitResult(success=False, output="git not found in PATH", command=cmd_str)
33
+
34
+
35
+ def clone(url: str, dest: Path) -> GitResult:
36
+ dest.parent.mkdir(parents=True, exist_ok=True)
37
+ return _run(["git", "clone", url, str(dest)])
38
+
39
+
40
+ def pull(repo_path: Path) -> GitResult:
41
+ return _run(["git", "pull"], cwd=repo_path)
42
+
43
+
44
+ def push(repo_path: Path) -> GitResult:
45
+ return _run(["git", "push"], cwd=repo_path)
46
+
47
+
48
+ def status(repo_path: Path) -> GitResult:
49
+ return _run(["git", "status", "--porcelain"], cwd=repo_path)
50
+
51
+
52
+ def current_branch(repo_path: Path) -> GitResult:
53
+ return _run(["git", "rev-parse", "--abbrev-ref", "HEAD"], cwd=repo_path)
54
+
55
+
56
+ def ahead_behind(repo_path: Path) -> tuple[int, int]:
57
+ """Return (ahead, behind) counts relative to upstream."""
58
+ result = _run(["git", "rev-list", "--left-right", "--count", "HEAD...@{upstream}"], cwd=repo_path)
59
+ if not result.success:
60
+ return 0, 0
61
+ parts = result.output.split()
62
+ if len(parts) == 2:
63
+ return int(parts[0]), int(parts[1])
64
+ return 0, 0
65
+
66
+
67
+ def last_commit(repo_path: Path) -> str:
68
+ result = _run(["git", "log", "-1", "--format=%s"], cwd=repo_path)
69
+ return result.output if result.success else ""
70
+
71
+
72
+ def fetch(repo_path: Path) -> GitResult:
73
+ return _run(["git", "fetch", "--prune"], cwd=repo_path)
74
+
75
+
76
+ def checkout(repo_path: Path, branch: str) -> GitResult:
77
+ """Checkout a branch. Try local first, then track remote."""
78
+ result = _run(["git", "checkout", branch], cwd=repo_path)
79
+ if not result.success and "did not match" in result.output:
80
+ # Try to create local branch tracking remote
81
+ result = _run(["git", "checkout", "-b", branch, f"origin/{branch}"], cwd=repo_path)
82
+ return result
83
+
84
+
85
+ def list_remote_branches(repo_path: Path, pattern: str) -> list[str]:
86
+ """List remote branches matching a glob pattern, sorted by committerdate (newest first)."""
87
+ import fnmatch
88
+
89
+ result = _run(
90
+ ["git", "branch", "-r", "--sort=-committerdate", "--format=%(refname:short)"],
91
+ cwd=repo_path,
92
+ )
93
+ if not result.success:
94
+ return []
95
+
96
+ branches = []
97
+ for line in result.output.splitlines():
98
+ line = line.strip()
99
+ # Remove origin/ prefix for matching
100
+ branch_name = line.removeprefix("origin/")
101
+ if fnmatch.fnmatch(branch_name, pattern):
102
+ branches.append(branch_name)
103
+ return branches
gitmux/hooks.py ADDED
@@ -0,0 +1,59 @@
1
+ """Hook execution and template merging logic."""
2
+
3
+ import subprocess
4
+ from dataclasses import dataclass
5
+ from pathlib import Path
6
+
7
+ from gitmux.models import GitmuxConfig, HookConfig, RepoConfig
8
+ from gitmux.output import console
9
+
10
+
11
+ @dataclass
12
+ class HookResult:
13
+ success: bool
14
+ failed_command: str | None = None
15
+ output: str = ""
16
+
17
+
18
+ def resolve_hooks(repo: RepoConfig, config: GitmuxConfig) -> HookConfig:
19
+ """Merge template hooks with repo-level hooks. Repo-level overrides template."""
20
+ if not repo.template:
21
+ return repo.hooks
22
+
23
+ template = config.templates.get(repo.template)
24
+ if not template:
25
+ return repo.hooks
26
+
27
+ # For each hook type, use repo's if non-empty, else template's
28
+ merged = HookConfig()
29
+ for field in ("pre_clone", "post_clone", "pre_pull", "post_pull", "pre_push", "post_push"):
30
+ repo_val = getattr(repo.hooks, field)
31
+ template_val = getattr(template, field)
32
+ setattr(merged, field, repo_val if repo_val else template_val)
33
+ return merged
34
+
35
+
36
+ def run_hooks(commands: list[str], cwd: Path, label: str = "") -> HookResult:
37
+ """Execute a list of hook commands sequentially in the given directory."""
38
+ if not commands:
39
+ return HookResult(success=True)
40
+
41
+ for cmd in commands:
42
+ if label:
43
+ console.print(f" [dim]hook ({label}):[/] {cmd}")
44
+ try:
45
+ result = subprocess.run(
46
+ cmd,
47
+ shell=True,
48
+ cwd=cwd,
49
+ capture_output=True,
50
+ text=True,
51
+ timeout=120,
52
+ )
53
+ if result.returncode != 0:
54
+ output = (result.stdout + result.stderr).strip()
55
+ return HookResult(success=False, failed_command=cmd, output=output)
56
+ except subprocess.TimeoutExpired:
57
+ return HookResult(success=False, failed_command=cmd, output="Timed out (120s)")
58
+
59
+ return HookResult(success=True)
gitmux/models.py ADDED
@@ -0,0 +1,63 @@
1
+ """Data models for gitmux configuration."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from pathlib import Path
5
+
6
+
7
+ @dataclass
8
+ class HookConfig:
9
+ pre_clone: list[str] = field(default_factory=list)
10
+ post_clone: list[str] = field(default_factory=list)
11
+ pre_pull: list[str] = field(default_factory=list)
12
+ post_pull: list[str] = field(default_factory=list)
13
+ pre_push: list[str] = field(default_factory=list)
14
+ post_push: list[str] = field(default_factory=list)
15
+
16
+
17
+ @dataclass
18
+ class RepoConfig:
19
+ name: str
20
+ url: str
21
+ path: str | None = None
22
+ template: str | None = None
23
+ hooks: HookConfig = field(default_factory=HookConfig)
24
+ branches: dict[str, str] = field(default_factory=dict) # e.g. {"prod": "a-plan-*", "dev": "a-dev-main"}
25
+
26
+
27
+ @dataclass
28
+ class GroupConfig:
29
+ name: str
30
+ repos: list[RepoConfig] = field(default_factory=list)
31
+
32
+
33
+ @dataclass
34
+ class GitmuxConfig:
35
+ workspace: str = "~/projects"
36
+ templates: dict[str, HookConfig] = field(default_factory=dict)
37
+ groups: list[GroupConfig] = field(default_factory=list)
38
+
39
+ def get_repo_path(self, repo: RepoConfig, group: GroupConfig) -> Path:
40
+ """Resolve the local path for a repo."""
41
+ if repo.path:
42
+ return Path(repo.path).expanduser()
43
+ return Path(self.workspace).expanduser() / group.name / repo.name
44
+
45
+ def find_repo(self, name: str) -> tuple[RepoConfig, GroupConfig] | None:
46
+ for group in self.groups:
47
+ for repo in group.repos:
48
+ if repo.name == name:
49
+ return repo, group
50
+ return None
51
+
52
+ def find_group(self, name: str) -> GroupConfig | None:
53
+ for group in self.groups:
54
+ if group.name == name:
55
+ return group
56
+ return None
57
+
58
+ def all_repos(self) -> list[tuple[RepoConfig, GroupConfig]]:
59
+ result = []
60
+ for group in self.groups:
61
+ for repo in group.repos:
62
+ result.append((repo, group))
63
+ return result
gitmux/output.py ADDED
@@ -0,0 +1,31 @@
1
+ """Output formatting for serial and parallel execution."""
2
+
3
+ import sys
4
+
5
+ from rich.console import Console
6
+ from rich.panel import Panel
7
+
8
+ console = Console()
9
+
10
+ # Use ASCII-safe symbols on Windows with non-UTF-8 encoding
11
+ _OK = "[green]OK[/]" if sys.platform == "win32" else "[green]✓[/]"
12
+ _FAIL = "[red]FAIL[/]" if sys.platform == "win32" else "[red]✗[/]"
13
+
14
+
15
+ def print_step(repo_name: str, step: str) -> None:
16
+ console.print(f" [bold cyan]{repo_name}[/] -> [dim]{step}[/]")
17
+
18
+
19
+ def print_success(repo_name: str, output: str = "") -> None:
20
+ console.print(f" [bold cyan]{repo_name}[/] {_OK}")
21
+ if output:
22
+ for line in output.splitlines():
23
+ console.print(f" [dim]{line}[/]")
24
+
25
+
26
+ def print_error(repo_name: str, error: str) -> None:
27
+ console.print(f" [bold cyan]{repo_name}[/] {_FAIL} {error}")
28
+
29
+
30
+ def print_header(title: str) -> None:
31
+ console.print(Panel(f"[bold]{title}[/]", expand=False))
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.4
2
+ Name: gitmux
3
+ Version: 0.1.0
4
+ Summary: Manage multiple git repositories with ease
5
+ Project-URL: Homepage, https://github.com/ryan/gitmux
6
+ Project-URL: Repository, https://github.com/ryan/gitmux
7
+ Project-URL: Issues, https://github.com/ryan/gitmux/issues
8
+ Author: Ryan
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: cli,devtools,git,multi-repo
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Version Control :: Git
22
+ Requires-Python: >=3.10
23
+ Requires-Dist: pyyaml>=6.0.2
24
+ Requires-Dist: rich>=13.9.4
25
+ Requires-Dist: typer>=0.15.4
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest-mock==3.14.0; extra == 'dev'
28
+ Requires-Dist: pytest==8.3.4; extra == 'dev'
29
+ Requires-Dist: ruff==0.11.12; extra == 'dev'
30
+ Description-Content-Type: text/markdown
31
+
32
+ # gitmux
33
+
34
+ Manage multiple git repositories with ease. Clone, pull, push, and run commands across repos with a single command.
35
+
36
+ ## Features
37
+
38
+ - **YAML configuration** — declarative repo management
39
+ - **Group management** — organize repos into groups
40
+ - **Batch git operations** — clone/pull/push across repos
41
+ - **Pre/post hooks** — run commands before/after git operations (e.g., `npm install` after pull)
42
+ - **Template system** — share hook configs across similar repos
43
+ - **Parallel execution** — speed up operations with `--parallel` flag
44
+ - **Status overview** — see all repos' git status at a glance
45
+ - **Arbitrary command execution** — run any shell command across repos
46
+
47
+ ## Install
48
+
49
+ ```bash
50
+ pip install gitmux
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ```bash
56
+ # Initialize config in current directory
57
+ gitmux init
58
+
59
+ # Add repos (default group if --group omitted)
60
+ gitmux add git@github.com:user/api-server.git --group backend
61
+ gitmux add git@github.com:user/auth-service.git --group backend
62
+
63
+ # Clone all repos
64
+ gitmux clone --all
65
+
66
+ # Pull a single repo
67
+ gitmux pull backend/api-server
68
+
69
+ # Pull entire group (parallel)
70
+ gitmux pull --group backend --parallel
71
+
72
+ # Check status of all repos
73
+ gitmux status
74
+
75
+ # Run command on a specific repo
76
+ gitmux exec "git checkout main" --target backend/api-server
77
+ ```
78
+
79
+ ## Configuration
80
+
81
+ Config file lookup order (used for both reading and writing):
82
+ 1. `--config / -c` flag (explicit path)
83
+ 2. `.gitmux.yaml` in current directory
84
+ 3. `~/.gitmux.yaml` (global fallback)
85
+
86
+ ```yaml
87
+ workspace: ~/projects
88
+
89
+ templates:
90
+ node-app:
91
+ post_pull:
92
+ - npm install
93
+ pre_push:
94
+ - npm test
95
+
96
+ groups:
97
+ backend:
98
+ repos:
99
+ - name: api-server
100
+ url: git@github.com:user/api-server.git
101
+ template: node-app
102
+ - name: auth-service
103
+ url: git@github.com:user/auth-service.git
104
+ path: ~/custom/path/auth # override default path
105
+ hooks:
106
+ post_pull:
107
+ - pip install -r requirements.txt
108
+ frontend:
109
+ repos:
110
+ - name: web-app
111
+ url: git@github.com:user/web-app.git
112
+ template: node-app
113
+ ```
114
+
115
+ ### Path Resolution
116
+
117
+ - Default: `{workspace}/{group}/{repo_name}`
118
+ - Override per-repo with the `path` field
119
+
120
+ ### Branch Management
121
+
122
+ Configure named branch aliases per repo:
123
+
124
+ ```yaml
125
+ repos:
126
+ - name: map
127
+ url: https://code.example.com/base/map.git
128
+ branches:
129
+ prod: "bInfinite-plan-*" # pattern (contains *)
130
+ dev: "bInfinite-dev-main" # fixed branch name
131
+ ```
132
+
133
+ Usage:
134
+
135
+ ```bash
136
+ gitmux pull map --branch dev # checkout fixed branch → pull
137
+ gitmux pull map --branch prod:latest # fetch → find newest matching branch → checkout → pull
138
+ gitmux pull map --branch prod:260515 # replace * → checkout bInfinite-plan-260515 → pull
139
+ gitmux pull --group base --branch dev # checkout fixed branch for all repos in group
140
+ ```
141
+
142
+ Rules:
143
+ - `--branch <alias>` — alias must be a fixed branch (no `*`), otherwise error
144
+ - `--branch <alias>:latest` — alias must be a pattern (has `*`), picks newest by commit date
145
+ - `--branch <alias>:<value>` — alias must be a pattern, replaces `*` with `<value>`
146
+
147
+ ### Hook System
148
+
149
+ Hooks run shell commands before/after git operations:
150
+
151
+ - `pre_clone`, `post_clone`
152
+ - `pre_pull`, `post_pull`
153
+ - `pre_push`, `post_push`
154
+
155
+ **Error handling:**
156
+ - Pre-hook failure → git operation is skipped
157
+ - Post-hook failure → repo marked as failed
158
+
159
+ **Template merging:** Repo-level hooks override template hooks per hook type.
160
+
161
+ ## Commands
162
+
163
+ | Command | Description |
164
+ |---------|-------------|
165
+ | `gitmux init` | Create `.gitmux.yaml` in current dir (`--global` for `~/.gitmux.yaml`) |
166
+ | `gitmux add <url> --group <g>` | Add a repository (group auto-created) |
167
+ | `gitmux remove <name>` | Remove a repository |
168
+ | `gitmux list` | List all repositories |
169
+ | `gitmux status [target]` | Show git status overview (defaults to all) |
170
+ | `gitmux clone <target>` | Clone unclosed repositories |
171
+ | `gitmux fetch <target>` | Fetch remote data (`--branches` to list branches) |
172
+ | `gitmux pull <target>` | Pull latest changes |
173
+ | `gitmux push <target>` | Push local commits |
174
+ | `gitmux exec <cmd>` | Run command in repos (`--target` to specify) |
175
+ | `gitmux group list` | List groups |
176
+ | `gitmux group create <name>` | Create a group |
177
+ | `gitmux group remove <name>` | Remove a group |
178
+
179
+ ### Target Syntax
180
+
181
+ ```bash
182
+ gitmux pull map # repo 'map' in default group
183
+ gitmux pull base/map # repo 'map' in group 'base'
184
+ gitmux pull --group base # all repos in group 'base'
185
+ gitmux pull --all # all repos (explicit)
186
+ gitmux pull # error: specify target, --group, or --all
187
+ ```
188
+
189
+ Note: `gitmux add <url>` without `--group` places the repo in the `default` group.
190
+
191
+ ### Common Options
192
+
193
+ - `--group, -g` — operate on entire group
194
+ - `--all, -a` — operate on all repositories (required for write operations without target)
195
+ - `--parallel, -p` — run in parallel (clone/fetch/pull/push/exec)
196
+ - `--config, -c` — custom config file path
197
+
198
+ ## Development
199
+
200
+ ```bash
201
+ git clone https://github.com/ryan/gitmux.git
202
+ cd gitmux
203
+ pip install -e ".[dev]"
204
+ pytest
205
+ ```
206
+
207
+ ### Code Quality
208
+
209
+ Uses [Ruff](https://docs.astral.sh/ruff/) for linting and formatting:
210
+
211
+ ```bash
212
+ ruff check . # lint
213
+ ruff check --fix . # auto-fix
214
+ ruff format . # format
215
+ ```
216
+
217
+ Rules: `E`, `F`, `W`, `I` (isort), `N`, `UP` (modern Python), `B` (bugbear), `SIM`.
218
+
219
+ ## License
220
+
221
+ MIT
@@ -0,0 +1,13 @@
1
+ gitmux/__init__.py,sha256=olcNLhFCvmvqLi1yPEWL762ePJCSuJ8ACrVRUepRU1w,82
2
+ gitmux/cli.py,sha256=qz2UY4rhLrNrGaTfBTZJRoAqyRQZYd7AbiCsKdACWmg,19629
3
+ gitmux/config.py,sha256=IEArNglEGVyztRjXBiy8b_JH0rpNlh7OJqyPFGUnrAA,4177
4
+ gitmux/executor.py,sha256=gtq74tizisgcACyCWBrKB73sk9Qrn8qVwVgT1kTwbDg,4286
5
+ gitmux/git_ops.py,sha256=B5SJRHngFZSSPr7H8YWNh28ls-uXB7GSZT8ArSrICf8,3244
6
+ gitmux/hooks.py,sha256=ME5HwpCyNEyuETsu9VxzlxLEL4zi6PZHSJ7bqPIJHDE,1935
7
+ gitmux/models.py,sha256=ygDlHFalitnl5csdUcPJMqSqJvMGEYkPVJQdy7XPojw,1971
8
+ gitmux/output.py,sha256=PAZh2rR7BU_QzOCfVJiKUBH0-nS0X_zgg2Y1J8r5Do8,920
9
+ gitmux-0.1.0.dist-info/METADATA,sha256=NIdTOfNqQOIpOf7g2i1PNnjHS8BZUgdg0gPmr_VfLOc,6540
10
+ gitmux-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
11
+ gitmux-0.1.0.dist-info/entry_points.txt,sha256=fzr2NC5MI3Eki1X79tl-9BCijeqD6XL_Xf24b0-FXTw,42
12
+ gitmux-0.1.0.dist-info/licenses/LICENSE,sha256=h8B4q52QowRPNZ5rVj1Oav6nqgYIl89PIWGGh7OFZ5Y,1061
13
+ gitmux-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ gitmux = gitmux.cli:app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ryan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.