git-multi-status 0.0.1__tar.gz → 0.1.0__tar.gz

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.
Files changed (34) hide show
  1. git_multi_status-0.1.0/.github/dependabot.yml +11 -0
  2. git_multi_status-0.1.0/.github/workflows/ci.yml +48 -0
  3. git_multi_status-0.1.0/.github/workflows/publish.yml +22 -0
  4. git_multi_status-0.1.0/.gitignore +11 -0
  5. git_multi_status-0.1.0/.python-version +1 -0
  6. git_multi_status-0.1.0/PKG-INFO +49 -0
  7. git_multi_status-0.1.0/README.md +40 -0
  8. {git_multi_status-0.0.1 → git_multi_status-0.1.0}/pyproject.toml +13 -2
  9. git_multi_status-0.1.0/src/git_multi_status/__init__.py +10 -0
  10. git_multi_status-0.1.0/src/git_multi_status/__main__.py +102 -0
  11. git_multi_status-0.1.0/src/git_multi_status/config.py +76 -0
  12. git_multi_status-0.1.0/src/git_multi_status/display.py +134 -0
  13. git_multi_status-0.1.0/src/git_multi_status/git_utils.py +193 -0
  14. git_multi_status-0.1.0/src/git_multi_status/repo_finder.py +76 -0
  15. git_multi_status-0.1.0/src/git_multi_status/status_checker.py +258 -0
  16. git_multi_status-0.1.0/tests/__init__.py +1 -0
  17. git_multi_status-0.1.0/tests/conftest.py +117 -0
  18. git_multi_status-0.1.0/tests/test_config.py +124 -0
  19. git_multi_status-0.1.0/tests/test_display.py +244 -0
  20. git_multi_status-0.1.0/tests/test_git_utils.py +211 -0
  21. git_multi_status-0.1.0/tests/test_main.py +190 -0
  22. git_multi_status-0.1.0/tests/test_repo_finder.py +113 -0
  23. git_multi_status-0.1.0/tests/test_status_checker.py +151 -0
  24. git_multi_status-0.1.0/uv.lock +320 -0
  25. git_multi_status-0.0.1/PKG-INFO +0 -12
  26. git_multi_status-0.0.1/README.md +0 -3
  27. git_multi_status-0.0.1/setup.cfg +0 -4
  28. git_multi_status-0.0.1/src/git_multi_status/__main__.py +0 -410
  29. git_multi_status-0.0.1/src/git_multi_status.egg-info/PKG-INFO +0 -12
  30. git_multi_status-0.0.1/src/git_multi_status.egg-info/SOURCES.txt +0 -9
  31. git_multi_status-0.0.1/src/git_multi_status.egg-info/dependency_links.txt +0 -1
  32. git_multi_status-0.0.1/src/git_multi_status.egg-info/entry_points.txt +0 -2
  33. git_multi_status-0.0.1/src/git_multi_status.egg-info/requires.txt +0 -2
  34. git_multi_status-0.0.1/src/git_multi_status.egg-info/top_level.txt +0 -1
@@ -0,0 +1,11 @@
1
+ # To get started with Dependabot version updates, you'll need to specify which
2
+ # package ecosystems to update and where the package manifests are located.
3
+ # Please see the documentation for all configuration options:
4
+ # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
+
6
+ version: 2
7
+ updates:
8
+ - package-ecosystem: "pip" # See documentation for possible values
9
+ directory: "/" # Location of package manifests
10
+ schedule:
11
+ interval: "daily"
@@ -0,0 +1,48 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+
16
+ - name: Set up Python 3.12
17
+ uses: actions/setup-python@v4
18
+ with:
19
+ python-version: "3.12"
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v5
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ uv sync --dev
27
+
28
+ - name: Run linting with ruff
29
+ run: |
30
+ uv run ruff check .
31
+ uv run ruff format --check .
32
+
33
+ - name: Run tests
34
+ run: |
35
+ uv run pytest tests/ -v --cov=git_multi_status --cov-report=xml --cov-report=term
36
+
37
+ - name: Upload coverage to Codecov
38
+ uses: codecov/codecov-action@v3
39
+ with:
40
+ file: ./coverage.xml
41
+ fail_ci_if_error: true
42
+
43
+ - name: Test CLI installation and basic functionality
44
+ run: |
45
+ uv run git-multi-status --help
46
+ uv run git-multi-status --version
47
+ # Test on current directory (should work since we're in a git repo)
48
+ uv run git-multi-status .
@@ -0,0 +1,22 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ deploy:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - name: Set up Python 3.12
13
+ uses: actions/setup-python@v4
14
+ with:
15
+ python-version: "3.12"
16
+ - name: Install uv
17
+ uses: astral-sh/setup-uv@v5
18
+ - name: Build and publish
19
+ run: |
20
+ uvx --from=toml-cli toml set --toml-path=pyproject.toml project.version $(git describe --tags --abbrev=0)
21
+ uv build
22
+ uv publish --token ${{ secrets.UV_PUBLISH_TOKEN }}
@@ -0,0 +1,11 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .ruff_cache
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-multi-status
3
+ Version: 0.1.0
4
+ Summary: Python port of multi-git-status
5
+ Requires-Python: >=3.10
6
+ Requires-Dist: rich>=14.0.0
7
+ Requires-Dist: typer>=0.15.2
8
+ Description-Content-Type: text/markdown
9
+
10
+ # Git Multi Status
11
+
12
+ List the status of multiple Git repositories in a directory.
13
+
14
+ ## Install
15
+
16
+ You can install using `pipx install git-multi-status` or `uvx git-multi-status`
17
+
18
+ ## Usage
19
+ ```
20
+ % git-multi-status --help
21
+
22
+ Usage: git-multi-status [OPTIONS] [DIR]
23
+
24
+ git-multi-status shows uncommitted, untracked and unpushed changes in multiple Git repositories.
25
+
26
+ ╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
27
+ │ dir [DIR] Dir to scan [default: .] │
28
+ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
29
+ ╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
30
+ │ -w Warn about dirs that are not Git repositories │
31
+ │ --no-ok -e Exclude repos that are 'ok' │
32
+ │ -f Do a 'git fetch' on each repo (slow for many repos) │
33
+ │ --throttle INTEGER Wait SEC seconds between each 'git fetch' (-f option) [default: 0] │
34
+ │ --depth -d INTEGER Scan depth: 0=no recursion, -1=unlimited, >0=max depth [default: 2] │
35
+ │ --flatten Show only one status per line │
36
+ │ -b Show currently checked out branch │
37
+ │ --no-push Limit output: hide push status │
38
+ │ --no-pull Limit output: hide pull status │
39
+ │ --no-upstream Limit output: hide upstream status │
40
+ │ --no-uncommitted Limit output: hide uncommitted changes │
41
+ │ --no-untracked Limit output: hide untracked files │
42
+ │ --no-stashes Limit output: hide stashes │
43
+ │ --version -v │
44
+ │ --debug Enable debug output │
45
+ │ --install-completion Install completion for the current shell. │
46
+ │ --show-completion Show completion for the current shell, to copy it or customize the installation. │
47
+ │ --help Show this message and exit. │
48
+ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
49
+ ```
@@ -0,0 +1,40 @@
1
+ # Git Multi Status
2
+
3
+ List the status of multiple Git repositories in a directory.
4
+
5
+ ## Install
6
+
7
+ You can install using `pipx install git-multi-status` or `uvx git-multi-status`
8
+
9
+ ## Usage
10
+ ```
11
+ % git-multi-status --help
12
+
13
+ Usage: git-multi-status [OPTIONS] [DIR]
14
+
15
+ git-multi-status shows uncommitted, untracked and unpushed changes in multiple Git repositories.
16
+
17
+ ╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
18
+ │ dir [DIR] Dir to scan [default: .] │
19
+ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
20
+ ╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
21
+ │ -w Warn about dirs that are not Git repositories │
22
+ │ --no-ok -e Exclude repos that are 'ok' │
23
+ │ -f Do a 'git fetch' on each repo (slow for many repos) │
24
+ │ --throttle INTEGER Wait SEC seconds between each 'git fetch' (-f option) [default: 0] │
25
+ │ --depth -d INTEGER Scan depth: 0=no recursion, -1=unlimited, >0=max depth [default: 2] │
26
+ │ --flatten Show only one status per line │
27
+ │ -b Show currently checked out branch │
28
+ │ --no-push Limit output: hide push status │
29
+ │ --no-pull Limit output: hide pull status │
30
+ │ --no-upstream Limit output: hide upstream status │
31
+ │ --no-uncommitted Limit output: hide uncommitted changes │
32
+ │ --no-untracked Limit output: hide untracked files │
33
+ │ --no-stashes Limit output: hide stashes │
34
+ │ --version -v │
35
+ │ --debug Enable debug output │
36
+ │ --install-completion Install completion for the current shell. │
37
+ │ --show-completion Show completion for the current shell, to copy it or customize the installation. │
38
+ │ --help Show this message and exit. │
39
+ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
40
+ ```
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "git-multi-status"
3
- version = "0.0.1"
3
+ version = "0.1.0"
4
4
  description = "Python port of multi-git-status"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -12,6 +12,10 @@ dependencies = [
12
12
  [project.scripts]
13
13
  git-multi-status = "git_multi_status.__main__:app"
14
14
 
15
+ [build-system]
16
+ requires = ["hatchling"]
17
+ build-backend = "hatchling.build"
18
+
15
19
  [tool.ruff]
16
20
  line-length = 120
17
21
  target-version = "py310"
@@ -21,8 +25,15 @@ select = ["F", "E", "W", "I", "PL"]
21
25
  ignore = ["E501", "W191", "PLR0913", "PLR0912", "PLR0915"]
22
26
 
23
27
  [tool.ruff.lint.isort]
24
- known-first-party = ["gronpy"]
28
+ known-first-party = ["git_multi_status"]
25
29
 
26
30
  [tool.ruff.lint.pylint]
27
31
  max-returns = 10
28
32
  max-branches = 20
33
+
34
+ [dependency-groups]
35
+ dev = [
36
+ "pytest>=8.4.0",
37
+ "pytest-cov>=6.1.1",
38
+ "pytest-mock>=3.14.1",
39
+ ]
@@ -0,0 +1,10 @@
1
+ """Git Multi Status - Check status of multiple git repositories."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("git-multi-status")
7
+ except PackageNotFoundError:
8
+ __version__ = "dev"
9
+
10
+ __all__ = ["__version__"]
@@ -0,0 +1,102 @@
1
+ # MIT license
2
+
3
+ import os
4
+ import time
5
+
6
+ import typer
7
+ from typing_extensions import Annotated
8
+
9
+ from . import __version__
10
+ from .config import Config
11
+ from .display import StatusDisplay
12
+ from .repo_finder import find_git_repositories
13
+ from .status_checker import StatusChecker
14
+
15
+ app = typer.Typer(
16
+ help="git-multi-status shows uncommitted, untracked and unpushed changes in multiple Git repositories."
17
+ )
18
+
19
+
20
+ def version_callback(value: bool):
21
+ """Print version and exit."""
22
+ if value:
23
+ print(__version__)
24
+ raise typer.Exit()
25
+
26
+
27
+ @app.command()
28
+ def main(
29
+ dir: Annotated[str, typer.Argument(..., help="Dir to scan")] = ".",
30
+ warn_not_repo: Annotated[bool, typer.Option("-w", help="Warn about dirs that are not Git repositories")] = False,
31
+ exclude_ok: Annotated[bool, typer.Option("-e", "--no-ok", help="Exclude repos that are 'ok'")] = False,
32
+ do_fetch: Annotated[bool, typer.Option("-f", help="Do a 'git fetch' on each repo (slow for many repos)")] = False,
33
+ throttle: Annotated[
34
+ int, typer.Option("--throttle", help="Wait SEC seconds between each 'git fetch' (-f option)")
35
+ ] = 0,
36
+ depth: Annotated[
37
+ int, typer.Option("-d", "--depth", help="Scan depth: 0=no recursion, -1=unlimited, >0=max depth")
38
+ ] = 2,
39
+ flatten: Annotated[bool, typer.Option("--flatten", help="Show only one status per line")] = False,
40
+ show_branch: Annotated[bool, typer.Option("-b", help="Show currently checked out branch")] = False,
41
+ no_push: Annotated[bool, typer.Option("--no-push", help="Limit output: hide push status")] = False,
42
+ no_pull: Annotated[bool, typer.Option("--no-pull", help="Limit output: hide pull status")] = False,
43
+ no_upstream: Annotated[bool, typer.Option("--no-upstream", help="Limit output: hide upstream status")] = False,
44
+ no_uncommitted: Annotated[
45
+ bool, typer.Option("--no-uncommitted", help="Limit output: hide uncommitted changes")
46
+ ] = False,
47
+ no_untracked: Annotated[bool, typer.Option("--no-untracked", help="Limit output: hide untracked files")] = False,
48
+ no_stashes: Annotated[bool, typer.Option("--no-stashes", help="Limit output: hide stashes")] = False,
49
+ _: Annotated[bool, typer.Option("-v", "--version", callback=version_callback, is_eager=True)] = None,
50
+ debug: Annotated[bool, typer.Option("--debug", help="Enable debug output")] = False,
51
+ ) -> None:
52
+ """
53
+ git-multi-status shows uncommitted, untracked and unpushed changes in multiple Git repositories.
54
+ """
55
+ # Create configuration
56
+ config = Config(
57
+ directory=os.path.abspath(dir),
58
+ exclude_ok=exclude_ok,
59
+ do_fetch=do_fetch,
60
+ throttle=throttle,
61
+ depth=depth,
62
+ flatten=flatten,
63
+ show_branch=show_branch,
64
+ no_push=no_push,
65
+ no_pull=no_pull,
66
+ no_upstream=no_upstream,
67
+ no_uncommitted=no_uncommitted,
68
+ no_untracked=no_untracked,
69
+ no_stashes=no_stashes,
70
+ warn_not_repo=warn_not_repo,
71
+ debug=debug,
72
+ )
73
+
74
+ # Initialize components
75
+ status_checker = StatusChecker(debug=debug)
76
+ display = StatusDisplay(config)
77
+
78
+ # Find repositories
79
+ repos = list(find_git_repositories(config.directory, config.depth, config.warn_not_repo))
80
+
81
+ all_repos_ok = True
82
+
83
+ # Process each repository
84
+ for repo_path in repos:
85
+ # Fetch if requested
86
+ if config.do_fetch:
87
+ status_checker.fetch_repository(repo_path)
88
+ if config.throttle > 0:
89
+ time.sleep(config.throttle)
90
+
91
+ # Check repository status
92
+ status = status_checker.check_repository(repo_path)
93
+ if status:
94
+ display.display_status(status)
95
+ all_repos_ok = all_repos_ok and status.is_ok
96
+
97
+ # Exit with appropriate code
98
+ raise typer.Exit(code=0 if all_repos_ok else 1)
99
+
100
+
101
+ if __name__ == "__main__":
102
+ app()
@@ -0,0 +1,76 @@
1
+ """Configuration models for git-multi-status."""
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Optional
5
+
6
+
7
+ @dataclass
8
+ class Config:
9
+ """Configuration for git-multi-status operations."""
10
+
11
+ # Display options
12
+ exclude_ok: bool = False
13
+ flatten: bool = False
14
+ show_branch: bool = False
15
+ warn_not_repo: bool = False
16
+
17
+ # Filter options
18
+ no_push: bool = False
19
+ no_pull: bool = False
20
+ no_upstream: bool = False
21
+ no_uncommitted: bool = False
22
+ no_untracked: bool = False
23
+ no_stashes: bool = False
24
+
25
+ # Fetch options
26
+ do_fetch: bool = False
27
+ throttle: int = 0
28
+
29
+ # Search options
30
+ depth: int = 2
31
+
32
+ # Debug
33
+ debug: bool = False
34
+
35
+ # Directory to scan
36
+ directory: str = "."
37
+
38
+
39
+ @dataclass
40
+ class RepoStatus:
41
+ """Status information for a git repository."""
42
+
43
+ path: str
44
+ current_branch: Optional[str] = None
45
+ needs_push_branches: list[str] = None
46
+ needs_pull_branches: list[str] = None
47
+ needs_upstream_branches: list[str] = None
48
+ has_uncommitted: bool = False
49
+ has_untracked: bool = False
50
+ stash_count: int = 0
51
+ is_locked: bool = False
52
+ is_ignored: bool = False
53
+ is_unsafe: bool = False
54
+
55
+ def __post_init__(self):
56
+ """Initialize mutable default values."""
57
+ if self.needs_push_branches is None:
58
+ self.needs_push_branches = []
59
+ if self.needs_pull_branches is None:
60
+ self.needs_pull_branches = []
61
+ if self.needs_upstream_branches is None:
62
+ self.needs_upstream_branches = []
63
+
64
+ @property
65
+ def is_ok(self) -> bool:
66
+ """Check if repository is in a clean state."""
67
+ return (
68
+ not self.needs_push_branches
69
+ and not self.needs_pull_branches
70
+ and not self.needs_upstream_branches
71
+ and not self.has_uncommitted
72
+ and not self.has_untracked
73
+ and self.stash_count == 0
74
+ and not self.is_locked
75
+ and not self.is_unsafe
76
+ )
@@ -0,0 +1,134 @@
1
+ """Display utilities for git-multi-status."""
2
+
3
+ from rich.console import Console
4
+ from rich.text import Text
5
+
6
+ from .config import Config, RepoStatus
7
+
8
+ console = Console()
9
+
10
+
11
+ class StatusDisplay:
12
+ """Handle display of repository status information."""
13
+
14
+ def __init__(self, config: Config):
15
+ """Initialize display handler.
16
+
17
+ Args:
18
+ config: Application configuration
19
+ """
20
+ self.config = config
21
+
22
+ def display_status(self, status: RepoStatus) -> None:
23
+ """Display status for a repository.
24
+
25
+ Args:
26
+ status: Repository status to display
27
+ """
28
+ # Handle special cases first
29
+ if status.is_unsafe:
30
+ self._print_status(status.path, "", "Unsafe ownership, owned by someone else. Skipping.", "purple bold")
31
+ return
32
+
33
+ if status.is_locked:
34
+ self._print_status(status.path, "", "Locked. Skipping.", "red bold")
35
+ return
36
+
37
+ if status.is_ignored:
38
+ return
39
+
40
+ # Skip OK repos if requested
41
+ if status.is_ok and self.config.exclude_ok:
42
+ return
43
+
44
+ # Get branch display
45
+ branch_display = ""
46
+ if self.config.show_branch and status.current_branch:
47
+ branch_display = f" ({status.current_branch})"
48
+
49
+ # Build status messages
50
+ status_parts = self._build_status_parts(status)
51
+
52
+ if self.config.flatten:
53
+ # Display each status on its own line
54
+ for status_text, style in status_parts:
55
+ self._print_status(status.path, branch_display, status_text, style)
56
+ # Display all statuses on one line
57
+ elif status_parts:
58
+ self._print_combined_status(status.path, branch_display, status_parts)
59
+
60
+ def _build_status_parts(self, status: RepoStatus) -> list[tuple[str, str]]:
61
+ """Build list of status parts to display.
62
+
63
+ Args:
64
+ status: Repository status
65
+
66
+ Returns:
67
+ List of (status_text, style) tuples
68
+ """
69
+ parts = []
70
+
71
+ # Push status
72
+ if status.needs_push_branches and not self.config.no_push:
73
+ branches = ",".join(status.needs_push_branches)
74
+ parts.append((f"Needs push ({branches})", "yellow bold"))
75
+
76
+ # Pull status
77
+ if status.needs_pull_branches and not self.config.no_pull:
78
+ branches = ",".join(status.needs_pull_branches)
79
+ parts.append((f"Needs pull ({branches})", "blue bold"))
80
+
81
+ # Upstream status
82
+ if status.needs_upstream_branches and not self.config.no_upstream:
83
+ branches = ",".join(status.needs_upstream_branches)
84
+ parts.append((f"Needs upstream ({branches})", "purple bold"))
85
+
86
+ # Uncommitted changes
87
+ if status.has_uncommitted and not self.config.no_uncommitted:
88
+ parts.append(("Uncommitted changes", "red bold"))
89
+
90
+ # Untracked files
91
+ if status.has_untracked and not self.config.no_untracked:
92
+ parts.append(("Untracked files", "cyan bold"))
93
+
94
+ # Stashes
95
+ if status.stash_count > 0 and not self.config.no_stashes:
96
+ parts.append((f"{status.stash_count} stashes", "yellow bold"))
97
+
98
+ # OK status
99
+ if not parts: # No issues found
100
+ parts.append(("ok", "green bold"))
101
+
102
+ return parts
103
+
104
+ def _print_status(self, path: str, branch: str, status_text: str, style: str) -> None:
105
+ """Print a single status line.
106
+
107
+ Args:
108
+ path: Repository path
109
+ branch: Branch display text
110
+ status_text: Status message
111
+ style: Rich style for the status
112
+ """
113
+ text = Text()
114
+ text.append(f"{path}{branch}: ")
115
+ text.append(status_text, style=style)
116
+ console.print(text)
117
+
118
+ def _print_combined_status(self, path: str, branch: str, status_parts: list[tuple[str, str]]) -> None:
119
+ """Print combined status on one line.
120
+
121
+ Args:
122
+ path: Repository path
123
+ branch: Branch display text
124
+ status_parts: List of (status_text, style) tuples
125
+ """
126
+ text = Text()
127
+ text.append(f"{path}{branch}: ")
128
+
129
+ for i, (status_text, style) in enumerate(status_parts):
130
+ text.append(status_text, style=style)
131
+ if i < len(status_parts) - 1:
132
+ text.append(" ")
133
+
134
+ console.print(text)