git-retro 0.2.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.
- git_retro-0.2.0/LICENSE +21 -0
- git_retro-0.2.0/PKG-INFO +166 -0
- git_retro-0.2.0/README.md +148 -0
- git_retro-0.2.0/git_retro/__init__.py +2 -0
- git_retro-0.2.0/git_retro/__main__.py +5 -0
- git_retro-0.2.0/git_retro/cli.py +112 -0
- git_retro-0.2.0/git_retro/core.py +388 -0
- git_retro-0.2.0/git_retro/demo.py +72 -0
- git_retro-0.2.0/git_retro/fonts/OFL-BricolageGrotesque.txt +93 -0
- git_retro-0.2.0/git_retro/fonts/OFL-JetBrainsMono.txt +93 -0
- git_retro-0.2.0/git_retro/fonts/display-800.woff2 +0 -0
- git_retro-0.2.0/git_retro/fonts/mono-600.woff2 +0 -0
- git_retro-0.2.0/git_retro/fonts/text-500.woff2 +0 -0
- git_retro-0.2.0/git_retro/render.py +16 -0
- git_retro-0.2.0/git_retro/template.html +810 -0
- git_retro-0.2.0/git_retro.egg-info/PKG-INFO +166 -0
- git_retro-0.2.0/git_retro.egg-info/SOURCES.txt +21 -0
- git_retro-0.2.0/git_retro.egg-info/dependency_links.txt +1 -0
- git_retro-0.2.0/git_retro.egg-info/entry_points.txt +2 -0
- git_retro-0.2.0/git_retro.egg-info/top_level.txt +1 -0
- git_retro-0.2.0/pyproject.toml +32 -0
- git_retro-0.2.0/setup.cfg +4 -0
- git_retro-0.2.0/tests/test_core.py +99 -0
git_retro-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 David Montanha
|
|
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.
|
git_retro-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: git-retro
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Your year in git as an animated, shareable story page. Runs 100% locally, zero dependencies.
|
|
5
|
+
Author: David Montanha
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Ryuks-py/git-retro
|
|
8
|
+
Keywords: git,wrapped,year in review,statistics,cli,developer-tools
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
License-File: git_retro/fonts/OFL-BricolageGrotesque.txt
|
|
16
|
+
License-File: git_retro/fonts/OFL-JetBrainsMono.txt
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# git retro
|
|
20
|
+
|
|
21
|
+
**Your year in git, as an animated story you can share.** One command reads the repositories on your machine (private ones included) and turns your commits into a Wrapped-style page: your busiest day, your longest streak, the hour you code the most, your languages, your latest-night commit, how you compare to last year and the kind of developer your commits say you are.
|
|
22
|
+
|
|
23
|
+
It runs **100% locally**. No account, no token, no upload. Your code never leaves your computer.
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
**[See the live demo →](https://ryuks-py.github.io/git-retro/)** · [team mode demo](https://ryuks-py.github.io/git-retro/team.html) · [em português](https://ryuks-py.github.io/git-retro/pt.html)
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pipx install git+https://github.com/Ryuks-py/git-retro
|
|
33
|
+
git-retro ~/code
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That's it: it finds every repository under `~/code`, keeps only your commits from this year and opens the page in your browser. Or try it without installing:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/Ryuks-py/git-retro && cd git-retro
|
|
40
|
+
python3 -m git_retro ~/code
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Python 3.10+ and `git`. No other dependencies.
|
|
44
|
+
|
|
45
|
+
## What's inside
|
|
46
|
+
|
|
47
|
+
| Slide | What it shows |
|
|
48
|
+
|---|---|
|
|
49
|
+
| Commits | total, repositories, active days, average per day |
|
|
50
|
+
| Lines | written vs. deleted |
|
|
51
|
+
| Your year, day by day | a calendar heatmap and your busiest day |
|
|
52
|
+
| Month by month | your most productive month |
|
|
53
|
+
| Streak | most days in a row with at least one commit |
|
|
54
|
+
| Your clock | a 24-hour radial chart and your peak hour |
|
|
55
|
+
| Your weekday | which day you commit the most |
|
|
56
|
+
| You are… | your strongest trait, out of 11 personas (below) |
|
|
57
|
+
| Latest commit | the commit closest to dawn, with its message |
|
|
58
|
+
| Languages | share of changed lines per language |
|
|
59
|
+
| Repositories | where you spent your time |
|
|
60
|
+
| Words of the year | the words you used most in commit messages, and how many commits were fixes |
|
|
61
|
+
| Biggest commit | the largest change you made in one go |
|
|
62
|
+
| Compared to last year | commits, active days, streak and lines vs. the year before, and whether your top language changed |
|
|
63
|
+
| Summary | everything on one page, with **Make a video for stories**: a 14-second animated MP4 (1080×1920) that tells your year in six scenes and ends on your card. On a phone, **Share to Instagram** opens the system share sheet (Stories, Feed, WhatsApp, LinkedIn…). The still image is there too. |
|
|
64
|
+
|
|
65
|
+

|
|
66
|
+
|
|
67
|
+
The video is encoded in your browser with WebCodecs and muxed into a regular MP4 (no upload, no ffmpeg). Browsers without WebCodecs fall back to recording in real time.
|
|
68
|
+
|
|
69
|
+
### Personas
|
|
70
|
+
|
|
71
|
+
Each one is a measured trait. The page picks the one where you stand out the most; *Office hours* only shows up when nothing else does.
|
|
72
|
+
|
|
73
|
+
| Persona | When |
|
|
74
|
+
|---|---|
|
|
75
|
+
| Night owl | 12%+ of commits between midnight and 5am |
|
|
76
|
+
| Weekend warrior | 30%+ on Saturday or Sunday |
|
|
77
|
+
| Marathoner | a streak of 21+ days |
|
|
78
|
+
| Code janitor | deleted 60%+ of what you wrote |
|
|
79
|
+
| Firefighter | 35%+ of commits are fixes |
|
|
80
|
+
| Polyglot | 4+ languages with at least 5% each |
|
|
81
|
+
| Turbo mode | 30%+ of commits on your busiest 10% of days |
|
|
82
|
+
| Loyal to one | 80%+ of commits in one repository |
|
|
83
|
+
| Early bird | 25%+ before 9am |
|
|
84
|
+
| Night shift | 35%+ after 6pm |
|
|
85
|
+
| Office hours | none of the above |
|
|
86
|
+
|
|
87
|
+
Navigate with **← →**, tap the sides, or swipe. Space pauses; press and hold also pauses.
|
|
88
|
+
|
|
89
|
+
## Team mode
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
git-retro --team ~/code/our-product
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The same story for everyone who committed to those repositories: a **Who did it** leaderboard with each person's persona, **Awards of the year** (most commits, longest streak, latest commit, most lines deleted, most fixes), the team's clock, calendar and languages, and a video with an extra leaderboard scene. Bots like Dependabot and GitHub Actions are left out, and people who used more than one e-mail are counted once. Made for the end-of-year post in the team channel.
|
|
96
|
+
|
|
97
|
+
## You have more than one e-mail? It figures that out
|
|
98
|
+
|
|
99
|
+
Most people commit with a personal e-mail, a work e-mail and whatever their laptop had configured. git retro starts from the `user.email` in your git config and joins every e-mail that was used with the same author name. If it still can't find you, it lists who it saw so you can say which one is you:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
git-retro ~/code --author me@personal.dev --author me@company.com
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Options
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
git-retro [paths ...] folders to scan (default: current folder)
|
|
109
|
+
-y, --year 2025 another year (default: this year; last year during January)
|
|
110
|
+
-a, --author EMAIL|NAME your identity, repeatable
|
|
111
|
+
--name "Ana" name on the first slide
|
|
112
|
+
--lang pt|en page language (default: from your system)
|
|
113
|
+
--no-messages hide commit messages from the page
|
|
114
|
+
--anonymize show repositories as projeto-A, projeto-B…
|
|
115
|
+
-o, --output FILE output file (default: git-retro-YEAR.html)
|
|
116
|
+
--depth 4 how deep to look for repositories
|
|
117
|
+
--team the whole team: leaderboard and awards
|
|
118
|
+
--demo a made-up year, to see it without your data
|
|
119
|
+
--no-open don't open the browser
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Sharing the page from work? `--no-messages --anonymize` keeps the stats and drops anything that could identify a client or project.
|
|
123
|
+
|
|
124
|
+
## How the numbers are counted
|
|
125
|
+
|
|
126
|
+
- Only commits **authored** in the chosen year, by you, across all branches, without merge commits. The same commit in two clones counts once.
|
|
127
|
+
- Lines ignore dependency and build folders (`node_modules`, `venv*`, `site-packages`, `vendor`, `dist`, `build`, migrations…), lock files, minified files, images and fonts.
|
|
128
|
+
- A single file with more than 5,000 changed lines, a data file (JSON, CSV, SQL…) with more than 1,500, or a whole commit with more than 30,000 is treated as generated or imported.
|
|
129
|
+
- What was left out is reported only in your terminal, never on the page you share.
|
|
130
|
+
|
|
131
|
+
## Privacy
|
|
132
|
+
|
|
133
|
+
The output is a single HTML file with the numbers and fonts inside. It loads nothing from anywhere, so it works offline and makes no network requests. What ends up in it: aggregate stats, repository names, your most used commit words and two commit messages (latest and biggest). Use `--no-messages` and `--anonymize` to remove them.
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
python3 -m unittest discover -s tests -t .
|
|
139
|
+
python3 -m git_retro --demo # regenerate with fake data
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Author
|
|
143
|
+
|
|
144
|
+
Made by David Montanha · [portfolio](https://ryuks-py.github.io)
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT. Bundled fonts: [Bricolage Grotesque](https://github.com/ateliertriay/bricolage) and [JetBrains Mono](https://github.com/JetBrains/JetBrainsMono), both under the SIL Open Font License (see `git_retro/fonts/`).
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
<details>
|
|
153
|
+
<summary><b>Em português</b></summary>
|
|
154
|
+
|
|
155
|
+
**A sua retrospectiva do ano no git, em formato de stories.** Um comando lê os repositórios do seu computador (inclusive os privados) e gera uma página animada: dia mais intenso, maior sequência, horário em que você mais programa, linguagens, o commit mais tarde da noite, a comparação com o ano anterior e que tipo de programador seus commits dizem que você é.
|
|
156
|
+
|
|
157
|
+
Roda **100% local**: sem conta, sem token, sem upload.
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
pipx install git+https://github.com/Ryuks-py/git-retro
|
|
161
|
+
git-retro ~/projetos
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
A página sai em português se o seu sistema estiver em português (ou use `--lang pt`). Usa mais de um e-mail nos commits? Ele junta sozinho os e-mails que aparecem com o mesmo nome; se precisar, passe `--author` quantas vezes quiser. Para compartilhar sem expor cliente nem projeto: `--no-messages --anonymize`.
|
|
165
|
+
|
|
166
|
+
</details>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# git retro
|
|
2
|
+
|
|
3
|
+
**Your year in git, as an animated story you can share.** One command reads the repositories on your machine (private ones included) and turns your commits into a Wrapped-style page: your busiest day, your longest streak, the hour you code the most, your languages, your latest-night commit, how you compare to last year and the kind of developer your commits say you are.
|
|
4
|
+
|
|
5
|
+
It runs **100% locally**. No account, no token, no upload. Your code never leaves your computer.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
**[See the live demo →](https://ryuks-py.github.io/git-retro/)** · [team mode demo](https://ryuks-py.github.io/git-retro/team.html) · [em português](https://ryuks-py.github.io/git-retro/pt.html)
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pipx install git+https://github.com/Ryuks-py/git-retro
|
|
15
|
+
git-retro ~/code
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
That's it: it finds every repository under `~/code`, keeps only your commits from this year and opens the page in your browser. Or try it without installing:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
git clone https://github.com/Ryuks-py/git-retro && cd git-retro
|
|
22
|
+
python3 -m git_retro ~/code
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Python 3.10+ and `git`. No other dependencies.
|
|
26
|
+
|
|
27
|
+
## What's inside
|
|
28
|
+
|
|
29
|
+
| Slide | What it shows |
|
|
30
|
+
|---|---|
|
|
31
|
+
| Commits | total, repositories, active days, average per day |
|
|
32
|
+
| Lines | written vs. deleted |
|
|
33
|
+
| Your year, day by day | a calendar heatmap and your busiest day |
|
|
34
|
+
| Month by month | your most productive month |
|
|
35
|
+
| Streak | most days in a row with at least one commit |
|
|
36
|
+
| Your clock | a 24-hour radial chart and your peak hour |
|
|
37
|
+
| Your weekday | which day you commit the most |
|
|
38
|
+
| You are… | your strongest trait, out of 11 personas (below) |
|
|
39
|
+
| Latest commit | the commit closest to dawn, with its message |
|
|
40
|
+
| Languages | share of changed lines per language |
|
|
41
|
+
| Repositories | where you spent your time |
|
|
42
|
+
| Words of the year | the words you used most in commit messages, and how many commits were fixes |
|
|
43
|
+
| Biggest commit | the largest change you made in one go |
|
|
44
|
+
| Compared to last year | commits, active days, streak and lines vs. the year before, and whether your top language changed |
|
|
45
|
+
| Summary | everything on one page, with **Make a video for stories**: a 14-second animated MP4 (1080×1920) that tells your year in six scenes and ends on your card. On a phone, **Share to Instagram** opens the system share sheet (Stories, Feed, WhatsApp, LinkedIn…). The still image is there too. |
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
The video is encoded in your browser with WebCodecs and muxed into a regular MP4 (no upload, no ffmpeg). Browsers without WebCodecs fall back to recording in real time.
|
|
50
|
+
|
|
51
|
+
### Personas
|
|
52
|
+
|
|
53
|
+
Each one is a measured trait. The page picks the one where you stand out the most; *Office hours* only shows up when nothing else does.
|
|
54
|
+
|
|
55
|
+
| Persona | When |
|
|
56
|
+
|---|---|
|
|
57
|
+
| Night owl | 12%+ of commits between midnight and 5am |
|
|
58
|
+
| Weekend warrior | 30%+ on Saturday or Sunday |
|
|
59
|
+
| Marathoner | a streak of 21+ days |
|
|
60
|
+
| Code janitor | deleted 60%+ of what you wrote |
|
|
61
|
+
| Firefighter | 35%+ of commits are fixes |
|
|
62
|
+
| Polyglot | 4+ languages with at least 5% each |
|
|
63
|
+
| Turbo mode | 30%+ of commits on your busiest 10% of days |
|
|
64
|
+
| Loyal to one | 80%+ of commits in one repository |
|
|
65
|
+
| Early bird | 25%+ before 9am |
|
|
66
|
+
| Night shift | 35%+ after 6pm |
|
|
67
|
+
| Office hours | none of the above |
|
|
68
|
+
|
|
69
|
+
Navigate with **← →**, tap the sides, or swipe. Space pauses; press and hold also pauses.
|
|
70
|
+
|
|
71
|
+
## Team mode
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git-retro --team ~/code/our-product
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The same story for everyone who committed to those repositories: a **Who did it** leaderboard with each person's persona, **Awards of the year** (most commits, longest streak, latest commit, most lines deleted, most fixes), the team's clock, calendar and languages, and a video with an extra leaderboard scene. Bots like Dependabot and GitHub Actions are left out, and people who used more than one e-mail are counted once. Made for the end-of-year post in the team channel.
|
|
78
|
+
|
|
79
|
+
## You have more than one e-mail? It figures that out
|
|
80
|
+
|
|
81
|
+
Most people commit with a personal e-mail, a work e-mail and whatever their laptop had configured. git retro starts from the `user.email` in your git config and joins every e-mail that was used with the same author name. If it still can't find you, it lists who it saw so you can say which one is you:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
git-retro ~/code --author me@personal.dev --author me@company.com
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Options
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
git-retro [paths ...] folders to scan (default: current folder)
|
|
91
|
+
-y, --year 2025 another year (default: this year; last year during January)
|
|
92
|
+
-a, --author EMAIL|NAME your identity, repeatable
|
|
93
|
+
--name "Ana" name on the first slide
|
|
94
|
+
--lang pt|en page language (default: from your system)
|
|
95
|
+
--no-messages hide commit messages from the page
|
|
96
|
+
--anonymize show repositories as projeto-A, projeto-B…
|
|
97
|
+
-o, --output FILE output file (default: git-retro-YEAR.html)
|
|
98
|
+
--depth 4 how deep to look for repositories
|
|
99
|
+
--team the whole team: leaderboard and awards
|
|
100
|
+
--demo a made-up year, to see it without your data
|
|
101
|
+
--no-open don't open the browser
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Sharing the page from work? `--no-messages --anonymize` keeps the stats and drops anything that could identify a client or project.
|
|
105
|
+
|
|
106
|
+
## How the numbers are counted
|
|
107
|
+
|
|
108
|
+
- Only commits **authored** in the chosen year, by you, across all branches, without merge commits. The same commit in two clones counts once.
|
|
109
|
+
- Lines ignore dependency and build folders (`node_modules`, `venv*`, `site-packages`, `vendor`, `dist`, `build`, migrations…), lock files, minified files, images and fonts.
|
|
110
|
+
- A single file with more than 5,000 changed lines, a data file (JSON, CSV, SQL…) with more than 1,500, or a whole commit with more than 30,000 is treated as generated or imported.
|
|
111
|
+
- What was left out is reported only in your terminal, never on the page you share.
|
|
112
|
+
|
|
113
|
+
## Privacy
|
|
114
|
+
|
|
115
|
+
The output is a single HTML file with the numbers and fonts inside. It loads nothing from anywhere, so it works offline and makes no network requests. What ends up in it: aggregate stats, repository names, your most used commit words and two commit messages (latest and biggest). Use `--no-messages` and `--anonymize` to remove them.
|
|
116
|
+
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
python3 -m unittest discover -s tests -t .
|
|
121
|
+
python3 -m git_retro --demo # regenerate with fake data
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Author
|
|
125
|
+
|
|
126
|
+
Made by David Montanha · [portfolio](https://ryuks-py.github.io)
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT. Bundled fonts: [Bricolage Grotesque](https://github.com/ateliertriay/bricolage) and [JetBrains Mono](https://github.com/JetBrains/JetBrainsMono), both under the SIL Open Font License (see `git_retro/fonts/`).
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
<details>
|
|
135
|
+
<summary><b>Em português</b></summary>
|
|
136
|
+
|
|
137
|
+
**A sua retrospectiva do ano no git, em formato de stories.** Um comando lê os repositórios do seu computador (inclusive os privados) e gera uma página animada: dia mais intenso, maior sequência, horário em que você mais programa, linguagens, o commit mais tarde da noite, a comparação com o ano anterior e que tipo de programador seus commits dizem que você é.
|
|
138
|
+
|
|
139
|
+
Roda **100% local**: sem conta, sem token, sem upload.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
pipx install git+https://github.com/Ryuks-py/git-retro
|
|
143
|
+
git-retro ~/projetos
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
A página sai em português se o seu sistema estiver em português (ou use `--lang pt`). Usa mais de um e-mail nos commits? Ele junta sozinho os e-mails que aparecem com o mesmo nome; se precisar, passe `--author` quantas vezes quiser. Para compartilhar sem expor cliente nem projeto: `--no-messages --anonymize`.
|
|
147
|
+
|
|
148
|
+
</details>
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""git retro: a sua retrospectiva do ano no git, gerada localmente."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import locale
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
import webbrowser
|
|
9
|
+
from datetime import date
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from . import __version__
|
|
13
|
+
from .core import compute, summary, team, is_bot, config_emails, find_repos, read_commits, resolve_identity, top_authors
|
|
14
|
+
from .render import render
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _default_lang():
|
|
18
|
+
for v in (os.environ.get("LC_ALL"), os.environ.get("LANG"), (locale.getlocale()[0] or "")):
|
|
19
|
+
if v:
|
|
20
|
+
return "pt" if v.lower().startswith("pt") else "en"
|
|
21
|
+
return "en"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def main(argv=None):
|
|
25
|
+
ap = argparse.ArgumentParser(prog="git-retro", description="Your year in git, as an animated story page. Runs 100%% locally.")
|
|
26
|
+
ap.add_argument("paths", nargs="*", default=["."], help="folders to scan for git repositories (default: current folder)")
|
|
27
|
+
ap.add_argument("-y", "--year", type=int, default=None, help="year to look at (default: this year, or last year in January)")
|
|
28
|
+
ap.add_argument("-a", "--author", action="append", default=[], help="your e-mail or name; repeat for each identity you use")
|
|
29
|
+
ap.add_argument("-o", "--output", default=None, help="output HTML file (default: git-retro-YEAR.html)")
|
|
30
|
+
ap.add_argument("--name", default=None, help="name shown on the page (default: your git user.name)")
|
|
31
|
+
ap.add_argument("--lang", choices=["pt", "en"], default=None, help="page language (default: from your system)")
|
|
32
|
+
ap.add_argument("--no-messages", action="store_true", help="hide commit messages from the page")
|
|
33
|
+
ap.add_argument("--anonymize", action="store_true", help="replace repository names with projeto-A, projeto-B…")
|
|
34
|
+
ap.add_argument("--depth", type=int, default=4, help="how deep to look for repositories (default: 4)")
|
|
35
|
+
ap.add_argument("--team", action="store_true", help="the whole team instead of just you: leaderboard and awards")
|
|
36
|
+
ap.add_argument("--demo", action="store_true", help="use a made-up year instead of your repositories")
|
|
37
|
+
ap.add_argument("--no-open", action="store_true", help="do not open the page in the browser")
|
|
38
|
+
ap.add_argument("--version", action="version", version=f"git-retro {__version__}")
|
|
39
|
+
a = ap.parse_args(argv)
|
|
40
|
+
|
|
41
|
+
today = date.today()
|
|
42
|
+
year = a.year or (today.year - 1 if today.month == 1 else today.year)
|
|
43
|
+
lang = a.lang or _default_lang()
|
|
44
|
+
say = (lambda pt, en: print(pt if lang == "pt" else en, file=sys.stderr))
|
|
45
|
+
|
|
46
|
+
if a.demo:
|
|
47
|
+
from .demo import demo_commits
|
|
48
|
+
mine = demo_commits(year, lang=lang, team=a.team)
|
|
49
|
+
prev = demo_commits(year - 1, seed=3, lang=lang, scale=.7, team=a.team)
|
|
50
|
+
name = a.name or ("Acme" if a.team else ("Você" if lang == "pt" else "You"))
|
|
51
|
+
else:
|
|
52
|
+
repos = find_repos(a.paths, a.depth)
|
|
53
|
+
if not repos:
|
|
54
|
+
say("Nenhum repositório git encontrado aqui. Passe a pasta onde ficam seus projetos: git-retro ~/projetos",
|
|
55
|
+
"No git repositories found here. Point it at your projects folder: git-retro ~/code")
|
|
56
|
+
return 1
|
|
57
|
+
say(f"→ {len(repos)} repositórios encontrados, lendo commits de {year}…",
|
|
58
|
+
f"→ found {len(repos)} repositories, reading {year} commits…")
|
|
59
|
+
commits = [c for r in repos for c in read_commits(r, year)]
|
|
60
|
+
before = [c for r in repos for c in read_commits(r, year - 1)]
|
|
61
|
+
if not commits:
|
|
62
|
+
say(f"Nenhum commit em {year} nesses repositórios.", f"No commits in {year} in those repositories.")
|
|
63
|
+
return 1
|
|
64
|
+
if a.team:
|
|
65
|
+
mine = [c for c in commits if not is_bot(c)]
|
|
66
|
+
prev = [c for c in before if not is_bot(c)]
|
|
67
|
+
roots = {Path(p).expanduser().resolve() for p in a.paths}
|
|
68
|
+
name = a.name or (next(iter(roots)).name if len(roots) == 1 else "")
|
|
69
|
+
else:
|
|
70
|
+
seeds = {x for x in a.author if "@" in x} or config_emails(repos)
|
|
71
|
+
names = {x for x in a.author if "@" not in x}
|
|
72
|
+
if not seeds and not names:
|
|
73
|
+
(email, nm), _ = top_authors(commits, 1)[0]
|
|
74
|
+
seeds = {email}
|
|
75
|
+
say(f" (sem user.email configurado; usando quem mais commitou: {nm} <{email}>)",
|
|
76
|
+
f" (no user.email configured; using the top committer: {nm} <{email}>)")
|
|
77
|
+
emails, names = resolve_identity(commits + before, seeds, names)
|
|
78
|
+
mine = [c for c in commits if c.email in emails or c.name.lower() in names]
|
|
79
|
+
prev = [c for c in before if c.email in emails or c.name.lower() in names]
|
|
80
|
+
say(f" você = {', '.join(sorted(emails))}", f" you = {', '.join(sorted(emails))}")
|
|
81
|
+
if not mine:
|
|
82
|
+
say("Nenhum commit seu encontrado. Quem aparece nesses repositórios:",
|
|
83
|
+
"None of the commits are yours. Who shows up in these repositories:")
|
|
84
|
+
for (email, nm), n in top_authors(commits):
|
|
85
|
+
print(f" {n:5} {nm} <{email}>", file=sys.stderr)
|
|
86
|
+
say("Rode de novo com --author seu@email (pode repetir).", "Run again with --author you@email (repeatable).")
|
|
87
|
+
return 1
|
|
88
|
+
name = a.name or (mine[-1].name.split()[0] if mine[-1].name else "")
|
|
89
|
+
|
|
90
|
+
data = compute(mine, year, show_messages=not a.no_messages, anonymize=a.anonymize, name=name)
|
|
91
|
+
data["lang"] = lang
|
|
92
|
+
if a.team:
|
|
93
|
+
data["team"] = team(mine, year)
|
|
94
|
+
say(f" time: {data['team']['size']} pessoas", f" team: {data['team']['size']} people")
|
|
95
|
+
data["prev"] = summary(compute(prev, year - 1)) if prev else None
|
|
96
|
+
ign = data.pop("_ignored")
|
|
97
|
+
out = Path(a.output or f"git-retro-{year}.html")
|
|
98
|
+
out.write_text(render(data), encoding="utf-8")
|
|
99
|
+
t = data["totals"]
|
|
100
|
+
say(f"✓ {t['commits']} commits em {t['repos']} repositórios → {out}",
|
|
101
|
+
f"✓ {t['commits']} commits across {t['repos']} repositories → {out}")
|
|
102
|
+
if ign["lines"]:
|
|
103
|
+
n = f"{ign['lines']:,}".replace(",", "." if lang == "pt" else ",")
|
|
104
|
+
say(f" ({n} linhas de dependências, build e importações ficaram fora da conta; a maior parte em {ign['top']})",
|
|
105
|
+
f" ({n} lines of dependencies, build output and imports were left out; mostly {ign['top']})")
|
|
106
|
+
if not a.no_open:
|
|
107
|
+
webbrowser.open(out.resolve().as_uri())
|
|
108
|
+
return 0
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if __name__ == "__main__":
|
|
112
|
+
sys.exit(main())
|