|
6 | 6 | Token Savings: 70-85% (structured metrics vs parsing git output) |
7 | 7 | """ |
8 | 8 |
|
9 | | -from coding_open_agent_tools.git import health |
10 | | -import tempfile |
11 | 9 | import subprocess |
| 10 | +import tempfile |
| 11 | + |
| 12 | +from coding_open_agent_tools.git import health |
12 | 13 |
|
13 | 14 | # Create a temporary git repository for demonstration |
14 | 15 | print("=" * 60) |
|
21 | 22 |
|
22 | 23 | # Initialize git repo |
23 | 24 | subprocess.run(["git", "init"], cwd=repo_path, capture_output=True) |
24 | | -subprocess.run(["git", "config", "user.name", "Demo User"], cwd=repo_path, capture_output=True) |
25 | | -subprocess.run(["git", "config", "user.email", "demo@example.com"], cwd=repo_path, capture_output=True) |
| 25 | +subprocess.run( |
| 26 | + ["git", "config", "user.name", "Demo User"], cwd=repo_path, capture_output=True |
| 27 | +) |
| 28 | +subprocess.run( |
| 29 | + ["git", "config", "user.email", "demo@example.com"], |
| 30 | + cwd=repo_path, |
| 31 | + capture_output=True, |
| 32 | +) |
26 | 33 |
|
27 | 34 | # Create some commits |
28 | 35 | for i in range(5): |
29 | 36 | with open(f"{repo_path}/file{i}.txt", "w") as f: |
30 | 37 | f.write(f"Content for file {i}\n" * 100) |
31 | 38 | subprocess.run(["git", "add", "."], cwd=repo_path, capture_output=True) |
32 | | - subprocess.run(["git", "commit", "-m", f"Commit {i+1}"], cwd=repo_path, capture_output=True) |
| 39 | + subprocess.run( |
| 40 | + ["git", "commit", "-m", f"Commit {i + 1}"], cwd=repo_path, capture_output=True |
| 41 | + ) |
33 | 42 |
|
34 | 43 | print("Demo repository created with 5 commits\n") |
35 | 44 |
|
|
56 | 65 | print(f"Loose objects: {gc_check['loose_objects_count']}") |
57 | 66 | print(f"Pack files: {gc_check['pack_files_count']}") |
58 | 67 | print(f"Repository size: {gc_check['repo_size_mb']} MB") |
59 | | -if gc_check['gc_needed'] == "true": |
| 68 | +if gc_check["gc_needed"] == "true": |
60 | 69 | print(f"Recommendations: {gc_check['recommendations']}") |
61 | 70 | print() |
62 | 71 |
|
|
67 | 76 |
|
68 | 77 | large_files = health.find_large_files(repo_path, "1") # Files > 1KB |
69 | 78 | print(f"Large files found: {large_files['large_files_count']}") |
70 | | -if int(large_files['large_files_count']) > 0: |
| 79 | +if int(large_files["large_files_count"]) > 0: |
71 | 80 | print(f"Files: {large_files['files_list']}") |
72 | 81 | print(f"Total size: {large_files['total_size_kb']} KB") |
73 | 82 | print() |
|
95 | 104 | health_check = health.check_repository_health(repo_path) |
96 | 105 | print(f"Has issues: {health_check['has_issues']}") |
97 | 106 | print(f"Issue count: {health_check['issue_count']}") |
98 | | -if int(health_check['issue_count']) > 0: |
| 107 | +if int(health_check["issue_count"]) > 0: |
99 | 108 | print(f"Issues: {health_check['issues']}") |
100 | 109 | print(f"Recommendations: {health_check['recommendations']}") |
101 | 110 | print() |
|
0 commit comments