git-contrib-tree 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.
@@ -0,0 +1,61 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ .Python
8
+ build/
9
+ develop-eggs/
10
+ dist/
11
+ downloads/
12
+ eggs/
13
+ .eggs/
14
+ lib/
15
+ lib64/
16
+ parts/
17
+ sdist/
18
+ var/
19
+ wheels/
20
+ pip-wheel-metadata/
21
+ share/python-wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+ MANIFEST
26
+
27
+ # PyInstaller
28
+ *.manifest
29
+ *.spec
30
+
31
+ # Installer logs
32
+ pip-log.txt
33
+ pip-delete-this-directory.txt
34
+
35
+ # Virtual environments
36
+ venv/
37
+ env/
38
+ ENV/
39
+ env.bak/
40
+ venv.bak/
41
+ .venv/
42
+
43
+ # IDEs
44
+ .vscode/
45
+ .idea/
46
+ *.swp
47
+ *.swo
48
+ *~
49
+ .DS_Store
50
+
51
+ # uv
52
+ .uv/
53
+
54
+ # Testing
55
+ .pytest_cache/
56
+ .coverage
57
+ htmlcov/
58
+ .tox/
59
+
60
+ # Ruff
61
+ .ruff_cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 wykwit
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.
@@ -0,0 +1,341 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-contrib-tree
3
+ Version: 0.1.0
4
+ Summary: Analyze and visualize git repository contributions with a file tree showing top contributors.
5
+ Project-URL: Repository, https://gitlab.com/wykwit/git-contrib-tree
6
+ Project-URL: Issues, https://gitlab.com/wykwit/git-contrib-tree/issues
7
+ Author-email: "Wiktor W." <wykwit@disroot.org>
8
+ License-File: LICENSE
9
+ Keywords: analysis,cli,contributions,git,tree,visualization
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Console
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.6
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Software Development :: Version Control :: Git
24
+ Classifier: Topic :: Utilities
25
+ Requires-Python: >=3.6
26
+ Description-Content-Type: text/markdown
27
+
28
+ # git-contrib-tree
29
+
30
+ A Python tool to analyze and visualize git repository contributions by displaying a file tree with the top 3 contributors for each file and directory.
31
+
32
+ > **Note:** This project was created with the assistance of Large Language Models (LLMs) for code generation, optimization, and documentation.
33
+
34
+ ## Features
35
+
36
+ - Display repository file tree with top contributors per file
37
+ - Show top 3 contributors for directories (aggregated from all files within)
38
+ - Show commit counts alongside contributor names
39
+ - Filter by date range (--since/--until)
40
+ - Filter by contributor email(s)
41
+ - List all contributor emails
42
+ - Control tree depth (useful for large repositories)
43
+ - Analyze specific subtrees within a repository
44
+
45
+ ## Requirements
46
+
47
+ - Python 3.6+
48
+ - Git installed and accessible in PATH
49
+ - A git repository to analyze
50
+
51
+ No external dependencies required - uses only Python standard library and git.
52
+
53
+ ## Installation
54
+
55
+ ### Using uv (Recommended)
56
+
57
+ ```bash
58
+ uv pip install git-contrib-tree
59
+ ```
60
+
61
+ ### Using pip
62
+
63
+ ```bash
64
+ pip install git-contrib-tree
65
+ ```
66
+
67
+ ### Arch Linux (AUR)
68
+
69
+ ```bash
70
+ # Using an AUR helper
71
+ paru -S git-contrib-tree
72
+ ```
73
+
74
+ This installs the `git-contrib-tree` command, making it available as both:
75
+ - A standalone command: `git-contrib-tree`
76
+ - A git subcommand: `git contrib-tree`
77
+
78
+ ### Development Installation
79
+
80
+ For development, clone the repository and install in editable mode:
81
+
82
+ ```bash
83
+ git clone https://gitlab.com/wykwit/git-contrib-tree.git
84
+ cd git-contrib-tree
85
+ uv pip install -e .
86
+ ```
87
+
88
+ ### Standalone Script
89
+
90
+ The `git-contrib-tree` script is a self-contained Python file with no external dependencies. You can use it directly without installing the package:
91
+
92
+ ```bash
93
+ # Download the script
94
+ curl -O https://gitlab.com/wykwit/git-contrib-tree/-/raw/main/git-contrib-tree
95
+ chmod +x git-contrib-tree
96
+
97
+ # Run it directly
98
+ ./git-contrib-tree --help
99
+
100
+ # Or with Python
101
+ python3 git-contrib-tree --help
102
+ ```
103
+
104
+ This is useful for:
105
+ - One-off usage without installation
106
+ - Including in other projects or scripts
107
+ - Running on systems where you can't install packages
108
+
109
+ ## Quick Start
110
+
111
+ ```bash
112
+ # Analyze current directory
113
+ git contrib-tree
114
+
115
+ # Show project-level overview
116
+ git contrib-tree --depth 0
117
+
118
+ # See who worked on what in the last quarter
119
+ git contrib-tree --since "3 months ago"
120
+
121
+ # List all contributors
122
+ git contrib-tree --list-emails
123
+ ```
124
+
125
+ ## Usage
126
+
127
+ ### Basic Usage
128
+
129
+ ```bash
130
+ # Analyze current directory
131
+ git contrib-tree
132
+
133
+ # Analyze specific repository
134
+ git contrib-tree --repo /path/to/repo
135
+ ```
136
+
137
+ ### Depth Control
138
+
139
+ ```bash
140
+ # Show only project-level contributors
141
+ git contrib-tree --depth 0
142
+
143
+ # Show root level only
144
+ git contrib-tree --depth 1
145
+
146
+ # Show files up to depth 2
147
+ git contrib-tree --depth 2
148
+
149
+ # Show all files (default)
150
+ git contrib-tree --depth -1
151
+ ```
152
+
153
+ **Note:** Depth controls what is *displayed*, not what is analyzed. Directory summaries always include all files within them, even if those files are not shown due to depth limits.
154
+
155
+ ### Analyze Specific Path
156
+
157
+ ```bash
158
+ # Analyze only the src directory
159
+ git contrib-tree --path src
160
+
161
+ # Analyze only src/models with depth 1
162
+ git contrib-tree --path src/models --depth 1
163
+
164
+ # Analyze specific file
165
+ git contrib-tree --path README.md --depth 0
166
+ ```
167
+
168
+ ### Date Filtering
169
+
170
+ ```bash
171
+ # Analyze contributions from specific date
172
+ git contrib-tree --since "2024-01-01"
173
+
174
+ # Analyze last 6 months
175
+ git contrib-tree --since "6 months ago"
176
+
177
+ # Analyze until specific date
178
+ git contrib-tree --until "2024-12-31"
179
+
180
+ # Analyze specific date range
181
+ git contrib-tree --since "2024-01-01" --until "2024-12-31"
182
+ ```
183
+
184
+ **Supported date formats:**
185
+ - Specific dates: `"2024-01-01"`, `"Jan 1 2024"`
186
+ - Relative dates: `"6 months ago"`, `"1 year ago"`, `"2 weeks ago"`
187
+ - ISO format: `"2024-01-01T00:00:00"`
188
+
189
+ ### Author Filtering
190
+
191
+ ```bash
192
+ # List all contributor emails
193
+ git contrib-tree --list-emails
194
+
195
+ # Filter by single author email
196
+ git contrib-tree --email user@example.com
197
+
198
+ # Filter by multiple authors (comma-separated)
199
+ git contrib-tree --email user1@example.com,user2@example.com
200
+
201
+ # Combine with other filters
202
+ git contrib-tree --email user@example.com --since "6 months ago" --depth 2
203
+ ```
204
+
205
+ ### Combined Examples
206
+
207
+ ```bash
208
+ # Analyze last year with depth 2
209
+ git contrib-tree --since "1 year ago" --depth 2
210
+
211
+ # Analyze specific repo and time period
212
+ git contrib-tree --repo ~/projects/myapp --since "2024-01-01" --depth 3
213
+
214
+ # Analyze src directory from last 6 months
215
+ git contrib-tree --path src --since "6 months ago" --depth 2
216
+
217
+ # See specific author's contributions in a directory
218
+ git contrib-tree --path src --email user@example.com
219
+ ```
220
+
221
+ ## Output Examples
222
+
223
+ ### Project Level (--depth 0)
224
+ ```
225
+ Project: my-repository
226
+ Top contributors: John Doe (150), Jane Smith (89), Bob Johnson (45)
227
+ ```
228
+
229
+ ### Tree View (Full Depth)
230
+ ```
231
+ Repository: my-repository
232
+
233
+ ├── README.md - John Doe (5), Jane Smith (2)
234
+ ├── src/ - John Doe (48), Jane Smith (23), Bob Johnson (10)
235
+ │ ├── main.py - John Doe (25), Bob Johnson (10), Jane Smith (3)
236
+ │ ├── utils.py - Jane Smith (15), John Doe (8)
237
+ │ └── models/ - Bob Johnson (20), John Doe (15), Jane Smith (5)
238
+ │ └── user.py - Bob Johnson (20), John Doe (5)
239
+ └── tests/ - Jane Smith (12), John Doe (8), Bob Johnson (2)
240
+ └── test_main.py - Jane Smith (12), John Doe (8), Bob Johnson (2)
241
+ ```
242
+
243
+ ### Tree View with Depth Limit (--depth 1)
244
+ ```
245
+ Repository: my-repository
246
+
247
+ ├── README.md - John Doe (5), Jane Smith (2)
248
+ ├── src/ - John Doe (48), Jane Smith (23), Bob Johnson (10)
249
+ └── tests/ - Jane Smith (12), John Doe (8), Bob Johnson (2)
250
+ ```
251
+
252
+ ### List Contributors (--list-emails)
253
+ ```
254
+ Contributors:
255
+ John Doe <john@example.com> - 150 commits
256
+ Jane Smith <jane@example.com> - 89 commits
257
+ Bob Johnson <bob@example.com> - 45 commits
258
+ ```
259
+
260
+ **Note:**
261
+ - Directory summaries show aggregated contributions from all files within that directory and its subdirectories
262
+ - Even when depth is limited, directory summaries include contributions from all nested files
263
+ - Files/directories with no contributions from filtered authors are hidden when using `--email`
264
+
265
+ ## Command Line Options
266
+
267
+ | Option | Default | Description |
268
+ |--------|---------|-------------|
269
+ | `--repo PATH` | `.` | Path to git repository |
270
+ | `--depth N` | `-1` | Maximum tree depth to display (0=project only, -1=unlimited) |
271
+ | `--path PATH` | None | Analyze only this path within the repository |
272
+ | `--since DATE` | None | Show commits after this date |
273
+ | `--until DATE` | None | Show commits before this date |
274
+ | `--email EMAILS` | None | Filter by author email(s), comma-separated |
275
+ | `--list-emails` | False | List all contributor emails and exit |
276
+
277
+ ## How It Works
278
+
279
+ The tool analyzes git history efficiently using batch operations:
280
+
281
+ 1. **File Discovery**: Uses `git ls-files` to get all tracked files (optionally filtered by path)
282
+ 2. **Tree Building**: Builds a complete file tree structure in memory
283
+ 3. **Batch Loading**: Runs a single `git log --name-only` command to get all commits and affected files
284
+ 4. **Efficient Parsing**: Parses the output to build contributor data for all files simultaneously
285
+ 5. **Bottom-Up Aggregation**: Calculates directory contributors by aggregating from files within
286
+ 6. **Smart Display**: Displays the tree up to the specified depth limit while maintaining accurate summaries
287
+
288
+ ## Use Cases
289
+
290
+ - **Code review**: Identify file owners and subject matter experts
291
+ - **Team analysis**: Understand contribution patterns across your codebase
292
+ - **Onboarding**: Help new team members identify who to ask about specific files
293
+ - **Project planning**: Visualize which parts of the codebase have concentrated knowledge
294
+ - **Historical analysis**: Track how contributions have changed over time using date filters
295
+ - **Individual tracking**: See what files a specific contributor has worked on
296
+ - **Refactoring**: Identify highly-modified files that might benefit from cleanup
297
+
298
+ ## Troubleshooting
299
+
300
+ **"Not a git repository" error:**
301
+ - Ensure you're in a git repository or use `--repo` to specify the path
302
+ - Run `git status` to verify the directory is a git repository
303
+
304
+ **No commits shown:**
305
+ - Check your date filters (`--since`, `--until`) - they might be excluding all commits
306
+ - Verify files exist in git: `git ls-files`
307
+ - Ensure the specified `--path` exists in the repository
308
+ - Check that the `--email` filter matches actual contributor emails (use `--list-emails`)
309
+
310
+ **Unexpected contributor names:**
311
+ - Git uses the name from commits, which may vary if contributors use different names
312
+ - Check commit history: `git log --format=%aN | sort -u`
313
+ - Use `--list-emails` to see all contributor emails and their associated names
314
+
315
+ ## License
316
+
317
+ This project is dual-licensed under the MIT License and WTFPL.
318
+
319
+ ```
320
+ MIT License
321
+
322
+ Copyright (c) 2025 wykwit
323
+
324
+ Permission is hereby granted, free of charge, to any person obtaining a copy
325
+ of this software and associated documentation files (the "Software"), to deal
326
+ in the Software without restriction, including without limitation the rights
327
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
328
+ copies of the Software, and to permit persons to whom the Software is
329
+ furnished to do so, subject to the following conditions:
330
+
331
+ The above copyright notice and this permission notice shall be included in all
332
+ copies or substantial portions of the Software.
333
+
334
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
335
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
336
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
337
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
338
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
339
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
340
+ SOFTWARE.
341
+ ```