gitlogstats 1.2.0__tar.gz → 1.4.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.
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/PKG-INFO +15 -7
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/README.md +14 -6
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/docs/SPEC.md +23 -5
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/pyproject.toml +1 -1
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/scripts/board/manifest.yaml +64 -15
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/src/gitlogstats/__main__.py +15 -3
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/src/gitlogstats/git_logs_parser.py +48 -3
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/src/gitlogstats/github.py +134 -9
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/src/gitlogstats/github_stats.py +56 -7
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/src/gitlogstats/identity.py +59 -15
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/pulls_page1.json +4 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/test_github.py +76 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/test_identity.py +82 -11
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/test_integration.py +637 -15
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/CLAUDE.md +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/agents/developer-agent.md +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/agents/spec-reviewer.md +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/hooks/format-edited.sh +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/hooks/guard-paths.sh +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/hooks/guard-paths.test.mjs +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/hooks/verify.sh +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/settings.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/skills/phase-handoff/SKILL.md +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.claude/skills/stale-check/SKILL.md +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.github/workflows/build.yaml +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.gitignore +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/.prettierrc.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/LICENSE +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/Pipfile +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/Pipfile.lock +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/package-lock.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/package.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/repos.txt +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/requirements.txt +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/scripts/board/config.mjs +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/scripts/board/derive.mjs +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/scripts/board/derive.test.mjs +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/scripts/board/sync.mjs +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/src/gitlogstats/__init__.py +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fake_gh.py +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/commit_linked.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/commit_unlinked.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/contributors.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/contributors_page2.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/pulls_page2.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/user_full.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/fixtures/github/user_private.json +0 -0
- {gitlogstats-1.2.0 → gitlogstats-1.4.0}/tests/test_git_logs_parser.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: gitlogstats
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.0
|
|
4
4
|
Summary: Track developers' contributions to one or more git repositories within a particular time range.
|
|
5
5
|
Project-URL: Homepage, https://github.com/bloombar/gitlogstats
|
|
6
6
|
Project-URL: Repository, https://github.com/bloombar/gitlogstats.git
|
|
@@ -709,7 +709,7 @@ This script calculates the following, for each developer in each repository:
|
|
|
709
709
|
- number of **files changed**
|
|
710
710
|
- number of **merges** into the analyzed branch
|
|
711
711
|
|
|
712
|
-
With `--github`, it also reports each developer's GitHub **pull requests** opened, merged, closed without merging and merged by themselves (see [GitHub pull requests](#github-pull-requests)).
|
|
712
|
+
With `--github`, it also reports each developer's GitHub **pull requests** opened, merged, closed without merging and merged by themselves, their **pushes** to the analyzed branch and their commits made on GitHub's **website** (see [GitHub pull requests](#github-pull-requests)).
|
|
713
713
|
|
|
714
714
|
The results can be formatted as `csv`, `json`, or `markdown`.
|
|
715
715
|
|
|
@@ -752,9 +752,11 @@ options:
|
|
|
752
752
|
-v, --verbose Whether to output debugging info
|
|
753
753
|
-c, --clean Remove contributors without any contribuition
|
|
754
754
|
--github Also report GitHub pull requests opened, merged,
|
|
755
|
-
closed and self-merged per contributor,
|
|
756
|
-
GitHub
|
|
757
|
-
|
|
755
|
+
closed and self-merged per contributor, with their git
|
|
756
|
+
and GitHub emails, their pushes to the analyzed branch
|
|
757
|
+
and their commits made on the GitHub website, and
|
|
758
|
+
match GitHub users to git authors. Needs the GitHub
|
|
759
|
+
CLI (gh), signed in
|
|
758
760
|
```
|
|
759
761
|
|
|
760
762
|
In case `gitlogstats` is not found as a command, even after installing, try `python -m gitlogstats` or `python3 -m gitlogstats` instead.
|
|
@@ -837,7 +839,7 @@ gitlogstats -rf repos.txt -c
|
|
|
837
839
|
|
|
838
840
|
### GitHub pull requests
|
|
839
841
|
|
|
840
|
-
Add `--github` to also count each contributor's pull requests.
|
|
842
|
+
Add `--github` to also count each contributor's pull requests, pushes and website commits. Nine columns are appended to every output format:
|
|
841
843
|
|
|
842
844
|
| Column | Meaning |
|
|
843
845
|
| --------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
@@ -846,6 +848,10 @@ Add `--github` to also count each contributor's pull requests. Five columns are
|
|
|
846
848
|
| `prs_merged` | pull requests they authored that were merged in the date range, by anyone and in any way (squash too) |
|
|
847
849
|
| `prs_closed_unmerged` | pull requests they authored that were closed without merging in the date range |
|
|
848
850
|
| `prs_self_merged` | pull requests they authored and also merged themselves, merged in the date range (also in `prs_merged`) |
|
|
851
|
+
| `git_email` | every distinct author email of the git names combined into the row, sorted alphabetically (ignoring case) and separated by `; `; empty for a GitHub-only row |
|
|
852
|
+
| `github_email` | the public email on the matched GitHub profile; empty when the profile has none (GitHub does not reveal private emails) or no account matched |
|
|
853
|
+
| `pushes_to_default` | times they pushed directly to the analyzed branch (the default branch, or the `-b` branch) in the date range; each push counts once however many commits it carries. Pull request merges, merge-queue merges and creating or deleting branches are not pushes |
|
|
854
|
+
| `web_commits` | their commits counted in `commits` that were made on GitHub's website (committer `GitHub <noreply@github.com>`), such as editing, creating, deleting or uploading a file in the browser; never more than `commits`. The commit GitHub makes when it squash- or rebase-merges a pull request is not counted |
|
|
849
855
|
|
|
850
856
|
```
|
|
851
857
|
gitlogstats -r https://github.com/bloombar/gitlogstats.git --github
|
|
@@ -858,7 +864,9 @@ gitlogstats: --github needs the GitHub CLI (gh), which is not installed. Install
|
|
|
858
864
|
gitlogstats: --github needs the GitHub CLI (gh) to be signed in. Run 'gh auth login', or run without --github.
|
|
859
865
|
```
|
|
860
866
|
|
|
861
|
-
**Empty versus zero.** A zero means GitHub was asked and the person has none. An empty value (`null` in JSON) means GitHub could not be asked for that repository: it is not on github.com, or the request failed (no network, rate limit, a private repository you cannot see). The git statistics are still reported, the reason is printed to standard error, and the other repositories carry on. A contributor with no GitHub account matched has an empty `github_username` and zero pull requests. A GitHub user who opened pull requests but has no commits is listed in a row of their own with an empty `username` and zero git statistics.
|
|
867
|
+
**Empty versus zero.** A zero means GitHub was asked and the person has none. An empty value (`null` in JSON) means GitHub could not be asked for that repository: it is not on github.com, or the request failed (no network, rate limit, a private repository you cannot see). The git statistics are still reported, the reason is printed to standard error, and the other repositories carry on. A contributor with no GitHub account matched has an empty `github_username` and zero pull requests. A GitHub user who opened pull requests but has no commits is listed in a row of their own with an empty `username` and zero git statistics. When GitHub could not be asked, `git_email` is still filled in and `github_email` is empty. The emails come from the whole history of the branch, not only from commits in the date range.
|
|
868
|
+
|
|
869
|
+
**Limits of pushes and website commits.** Pushes come from GitHub's repository activity record, which starts in September 2023: earlier pushes are not counted, however old the date range. A file edited on the website directly on the analyzed branch is recorded by GitHub as a push too, so it counts in both `pushes_to_default` and `web_commits`. Reading it works for any public repository you can see; for a private one you need access to it, and if GitHub refuses, the repository's GitHub columns are empty with the reason on standard error, as above. A push is credited to the GitHub user who pushed it, so a person who only pushes (and has no commits or pull requests in the range) still gets a row of their own. Pushes made while a tag or commit (not a branch) is checked out with `-b` are not counted. Website commits are recognised by GitHub being the committer, so commits made through GitHub's API, for example in the `github.dev` editor, are counted as website commits too, and so is the first commit GitHub creates when a repository is created on the website. Website commits follow `commits`: the same date range, exclusions (`-x`) and branch, credited to the commit's author and added up when names are combined into one row.
|
|
862
870
|
|
|
863
871
|
**Matching GitHub users to git authors.** Each git author name is compared with the GitHub users active in the repository, trying these in order and stopping at the first that finds exactly one user:
|
|
864
872
|
|
|
@@ -12,7 +12,7 @@ This script calculates the following, for each developer in each repository:
|
|
|
12
12
|
- number of **files changed**
|
|
13
13
|
- number of **merges** into the analyzed branch
|
|
14
14
|
|
|
15
|
-
With `--github`, it also reports each developer's GitHub **pull requests** opened, merged, closed without merging and merged by themselves (see [GitHub pull requests](#github-pull-requests)).
|
|
15
|
+
With `--github`, it also reports each developer's GitHub **pull requests** opened, merged, closed without merging and merged by themselves, their **pushes** to the analyzed branch and their commits made on GitHub's **website** (see [GitHub pull requests](#github-pull-requests)).
|
|
16
16
|
|
|
17
17
|
The results can be formatted as `csv`, `json`, or `markdown`.
|
|
18
18
|
|
|
@@ -55,9 +55,11 @@ options:
|
|
|
55
55
|
-v, --verbose Whether to output debugging info
|
|
56
56
|
-c, --clean Remove contributors without any contribuition
|
|
57
57
|
--github Also report GitHub pull requests opened, merged,
|
|
58
|
-
closed and self-merged per contributor,
|
|
59
|
-
GitHub
|
|
60
|
-
|
|
58
|
+
closed and self-merged per contributor, with their git
|
|
59
|
+
and GitHub emails, their pushes to the analyzed branch
|
|
60
|
+
and their commits made on the GitHub website, and
|
|
61
|
+
match GitHub users to git authors. Needs the GitHub
|
|
62
|
+
CLI (gh), signed in
|
|
61
63
|
```
|
|
62
64
|
|
|
63
65
|
In case `gitlogstats` is not found as a command, even after installing, try `python -m gitlogstats` or `python3 -m gitlogstats` instead.
|
|
@@ -140,7 +142,7 @@ gitlogstats -rf repos.txt -c
|
|
|
140
142
|
|
|
141
143
|
### GitHub pull requests
|
|
142
144
|
|
|
143
|
-
Add `--github` to also count each contributor's pull requests.
|
|
145
|
+
Add `--github` to also count each contributor's pull requests, pushes and website commits. Nine columns are appended to every output format:
|
|
144
146
|
|
|
145
147
|
| Column | Meaning |
|
|
146
148
|
| --------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
@@ -149,6 +151,10 @@ Add `--github` to also count each contributor's pull requests. Five columns are
|
|
|
149
151
|
| `prs_merged` | pull requests they authored that were merged in the date range, by anyone and in any way (squash too) |
|
|
150
152
|
| `prs_closed_unmerged` | pull requests they authored that were closed without merging in the date range |
|
|
151
153
|
| `prs_self_merged` | pull requests they authored and also merged themselves, merged in the date range (also in `prs_merged`) |
|
|
154
|
+
| `git_email` | every distinct author email of the git names combined into the row, sorted alphabetically (ignoring case) and separated by `; `; empty for a GitHub-only row |
|
|
155
|
+
| `github_email` | the public email on the matched GitHub profile; empty when the profile has none (GitHub does not reveal private emails) or no account matched |
|
|
156
|
+
| `pushes_to_default` | times they pushed directly to the analyzed branch (the default branch, or the `-b` branch) in the date range; each push counts once however many commits it carries. Pull request merges, merge-queue merges and creating or deleting branches are not pushes |
|
|
157
|
+
| `web_commits` | their commits counted in `commits` that were made on GitHub's website (committer `GitHub <noreply@github.com>`), such as editing, creating, deleting or uploading a file in the browser; never more than `commits`. The commit GitHub makes when it squash- or rebase-merges a pull request is not counted |
|
|
152
158
|
|
|
153
159
|
```
|
|
154
160
|
gitlogstats -r https://github.com/bloombar/gitlogstats.git --github
|
|
@@ -161,7 +167,9 @@ gitlogstats: --github needs the GitHub CLI (gh), which is not installed. Install
|
|
|
161
167
|
gitlogstats: --github needs the GitHub CLI (gh) to be signed in. Run 'gh auth login', or run without --github.
|
|
162
168
|
```
|
|
163
169
|
|
|
164
|
-
**Empty versus zero.** A zero means GitHub was asked and the person has none. An empty value (`null` in JSON) means GitHub could not be asked for that repository: it is not on github.com, or the request failed (no network, rate limit, a private repository you cannot see). The git statistics are still reported, the reason is printed to standard error, and the other repositories carry on. A contributor with no GitHub account matched has an empty `github_username` and zero pull requests. A GitHub user who opened pull requests but has no commits is listed in a row of their own with an empty `username` and zero git statistics.
|
|
170
|
+
**Empty versus zero.** A zero means GitHub was asked and the person has none. An empty value (`null` in JSON) means GitHub could not be asked for that repository: it is not on github.com, or the request failed (no network, rate limit, a private repository you cannot see). The git statistics are still reported, the reason is printed to standard error, and the other repositories carry on. A contributor with no GitHub account matched has an empty `github_username` and zero pull requests. A GitHub user who opened pull requests but has no commits is listed in a row of their own with an empty `username` and zero git statistics. When GitHub could not be asked, `git_email` is still filled in and `github_email` is empty. The emails come from the whole history of the branch, not only from commits in the date range.
|
|
171
|
+
|
|
172
|
+
**Limits of pushes and website commits.** Pushes come from GitHub's repository activity record, which starts in September 2023: earlier pushes are not counted, however old the date range. A file edited on the website directly on the analyzed branch is recorded by GitHub as a push too, so it counts in both `pushes_to_default` and `web_commits`. Reading it works for any public repository you can see; for a private one you need access to it, and if GitHub refuses, the repository's GitHub columns are empty with the reason on standard error, as above. A push is credited to the GitHub user who pushed it, so a person who only pushes (and has no commits or pull requests in the range) still gets a row of their own. Pushes made while a tag or commit (not a branch) is checked out with `-b` are not counted. Website commits are recognised by GitHub being the committer, so commits made through GitHub's API, for example in the `github.dev` editor, are counted as website commits too, and so is the first commit GitHub creates when a repository is created on the website. Website commits follow `commits`: the same date range, exclusions (`-x`) and branch, credited to the commit's author and added up when names are combined into one row.
|
|
165
173
|
|
|
166
174
|
**Matching GitHub users to git authors.** Each git author name is compared with the GitHub users active in the repository, trying these in order and stopping at the first that finds exactly one user:
|
|
167
175
|
|
|
@@ -120,11 +120,29 @@ With `--github`, for each contributor, the number of pull requests they authored
|
|
|
120
120
|
|
|
121
121
|
**Status:** Done
|
|
122
122
|
|
|
123
|
+
#### STAT-13 Contributor email addresses
|
|
124
|
+
|
|
125
|
+
With `--github`, every row also reports the contributor's email addresses in two columns appended after `prs_self_merged`: `git_email` lists every distinct author email of the git identities combined into the row (STAT-11), sorted alphabetically (ignoring case) and separated by `; `, and is empty for a GitHub-only row; `github_email` is the public email on the matched GitHub user's profile, and is empty when the profile has none (GitHub does not reveal private emails) or the row has no GitHub user. Emails come from the whole history of the analyzed branch, like the contributor list, not only from commits in the date range. When GitHub statistics are unavailable for a repository (CLI-3), `git_email` is still filled in and `github_email` is empty (`null` in JSON). Without `--github`, neither column appears.
|
|
126
|
+
|
|
127
|
+
**Status:** Done
|
|
128
|
+
|
|
129
|
+
#### STAT-14 Pushes to the analyzed branch
|
|
130
|
+
|
|
131
|
+
With `--github`, for each contributor, the number of times they pushed directly to the analyzed branch (the default branch, or the `-b` branch) in the date range, reported in a `pushes_to_default` column appended after `github_email`. Pushes come from GitHub's repository activity record (`repos/{owner}/{repo}/activity`), which names the GitHub user who pushed: activity types `push` and `force_push` count; pull-request merges, merge-queue merges and branch creation or deletion do not. One push counts once however many commits it carries. Each push is filtered by its own timestamp, using the same inclusive local-time range as FILT-1, and credited to the row of the GitHub user who pushed (STAT-11); a GitHub user with pushes but no other row gets a GitHub-only row. GitHub's activity record does not go back before September 2023, so older pushes are not counted. Without `-b`, the branch is the default branch; if the clone is on no branch (a tag or commit was checked out), no pushes are counted. GitHub lets anyone who can see a public repository read its activity record; a private repository needs access to it.
|
|
132
|
+
|
|
133
|
+
**Status:** Done
|
|
134
|
+
|
|
135
|
+
#### STAT-15 Commits made on the GitHub website
|
|
136
|
+
|
|
137
|
+
With `--github`, for each contributor, how many of their commits counted in `commits` (STAT-1: same date range, exclusions and branch, merges excluded) were made on GitHub's website rather than in a local clone, reported in a `web_commits` column appended after `pushes_to_default`, so `web_commits` is never larger than `commits`. A commit counts when GitHub created it — its committer is `GitHub <noreply@github.com>` — and it is not the result of merging a pull request: a commit GitHub created when squash- or rebase-merging a pull request is not a website commit. Such a commit is the merge commit GitHub names for a merged pull request, or was committed within 2 seconds of one (the other commits of a rebase merge); GitHub commits the result a few seconds before it marks the pull request merged, so the pull request's merge time is used only when GitHub names no merge commit. A named merge commit committed more than a minute before or after the merge time is the pull request's own head commit, which reached the branch another way, so that pull request excludes nothing. A commit GitHub created when a repository was created on the website (a root commit) counts like any other. Such commits are typically file edits, creations, deletions and uploads made in the browser; commits made through GitHub's API (e.g. `github.dev`) look the same and are counted too. Website commits are credited to the commit's author, like `commits`, and summed when identities are combined (STAT-11). When GitHub statistics are unavailable for a repository (CLI-3), `pushes_to_default` and `web_commits` are empty (`null` in JSON).
|
|
138
|
+
|
|
139
|
+
**Status:** Done
|
|
140
|
+
|
|
123
141
|
### 3. Filtering
|
|
124
142
|
|
|
125
143
|
#### FILT-1 Date range
|
|
126
144
|
|
|
127
|
-
`-s/--start` and `-e/--end` (format `mm/dd/yyyy`) limit the analysis to commits whose commit date falls between the start of the start date and the end of the end date, inclusive, in local time. Defaults: one year ago until today. The output records the requested start and end dates on every row. With `--github`, each pull request count is filtered by its own timestamp in the same range (CLI-3).
|
|
145
|
+
`-s/--start` and `-e/--end` (format `mm/dd/yyyy`) limit the analysis to commits whose commit date falls between the start of the start date and the end of the end date, inclusive, in local time. Defaults: one year ago until today. The output records the requested start and end dates on every row. With `--github`, each pull request and push count is filtered by its own timestamp in the same range (CLI-3).
|
|
128
146
|
|
|
129
147
|
**Status:** Done
|
|
130
148
|
|
|
@@ -142,7 +160,7 @@ With `--github`, for each contributor, the number of pull requests they authored
|
|
|
142
160
|
|
|
143
161
|
#### FILT-4 Remove inactive contributors
|
|
144
162
|
|
|
145
|
-
By default, contributors with no activity in the date range are listed with zeros. `-c/--clean` removes them. With `--github`, only rows with neither git
|
|
163
|
+
By default, contributors with no activity in the date range are listed with zeros. `-c/--clean` removes them. With `--github`, only rows with neither git, pull-request nor push activity are removed (CLI-3).
|
|
146
164
|
|
|
147
165
|
**Status:** Done
|
|
148
166
|
|
|
@@ -150,7 +168,7 @@ By default, contributors with no activity in the date range are listed with zero
|
|
|
150
168
|
|
|
151
169
|
#### OUT-1 CSV output
|
|
152
170
|
|
|
153
|
-
`-f csv` (the default) prints a header row followed by one row per contributor per repository, with fields `username, repository, start_date, end_date, commits, insertions, deletions, files, merges`. New fields are added at the end so existing column positions do not change. Values containing commas, quotes or line breaks are quoted. The header is printed even when there are no rows, and the output ends with a single newline. With `--github`, the columns `github_username, prs_opened, prs_merged, prs_closed_unmerged, prs_self_merged` are appended, and are in the header even when there are no rows (CLI-3).
|
|
171
|
+
`-f csv` (the default) prints a header row followed by one row per contributor per repository, with fields `username, repository, start_date, end_date, commits, insertions, deletions, files, merges`. New fields are added at the end so existing column positions do not change. Values containing commas, quotes or line breaks are quoted. The header is printed even when there are no rows, and the output ends with a single newline. With `--github`, the columns `github_username, prs_opened, prs_merged, prs_closed_unmerged, prs_self_merged, git_email, github_email, pushes_to_default, web_commits` are appended, and are in the header even when there are no rows (CLI-3).
|
|
154
172
|
|
|
155
173
|
**Status:** Done
|
|
156
174
|
|
|
@@ -194,12 +212,12 @@ Invalid dates, and a start date after the end date, are rejected with a usage er
|
|
|
194
212
|
|
|
195
213
|
#### CLI-3 GitHub pull-request statistics
|
|
196
214
|
|
|
197
|
-
`--github` adds GitHub pull-request statistics (STAT-8 to STAT-12) for repositories hosted on github.com, appending the columns `github_username, prs_opened, prs_merged, prs_closed_unmerged, prs_self_merged` to every output format. Without `--github`, the output and behaviour are unchanged, GitHub is never contacted and the GitHub CLI (`gh`) is not needed. With `--github`, the GitHub API is called through `gh api`, so `gh` must be installed and signed in. This is checked before any repository is cloned; if it fails, nothing is printed to standard output, the tool exits with status 1, and one plain message on standard error says why and what to do — no stack trace:
|
|
215
|
+
`--github` adds GitHub pull-request statistics (STAT-8 to STAT-12), contributor emails (STAT-13), pushes to the analyzed branch (STAT-14) and website commits (STAT-15) for repositories hosted on github.com, appending the columns `github_username, prs_opened, prs_merged, prs_closed_unmerged, prs_self_merged, git_email, github_email, pushes_to_default, web_commits` to every output format. Without `--github`, the output and behaviour are unchanged, GitHub is never contacted and the GitHub CLI (`gh`) is not needed. With `--github`, the GitHub API is called through `gh api`, so `gh` must be installed and signed in. This is checked before any repository is cloned; if it fails, nothing is printed to standard output, the tool exits with status 1, and one plain message on standard error says why and what to do — no stack trace:
|
|
198
216
|
|
|
199
217
|
- `gh` not found: `gitlogstats: --github needs the GitHub CLI (gh), which is not installed. Install it from https://cli.github.com and run 'gh auth login', or run without --github.`
|
|
200
218
|
- `gh` not signed in (`gh auth status` fails): `gitlogstats: --github needs the GitHub CLI (gh) to be signed in. Run 'gh auth login', or run without --github.`
|
|
201
219
|
|
|
202
|
-
The other options apply to pull requests as follows: `-s/-e` filter each count by its own timestamp, using the same inclusive local-time range as FILT-1; `-u` selects the combined row whose author names, emails or GitHub username match exactly (the username ignoring case); `-b` counts only pull requests whose base branch is that branch, and without `-b` every pull request counts; `-c` removes only rows with neither git
|
|
220
|
+
The other options apply to pull requests as follows: `-s/-e` filter each count by its own timestamp, using the same inclusive local-time range as FILT-1; `-u` selects the combined row whose author names, emails or GitHub username match exactly (the username ignoring case); `-b` counts only pull requests whose base branch is that branch, and without `-b` every pull request counts; `-c` removes only rows with neither git, pull-request nor push activity; `-x` does not apply to pull requests or pushes (it limits which commits count as website commits, as it does for `commits`); `-b` also selects the branch whose pushes are counted. For a repository not on github.com, or when GitHub cannot be reached for one repository (no network, rate limit, private repository without access), the git statistics are still reported, the GitHub columns (including `github_email`, `pushes_to_default` and `web_commits`) are empty (`null` in JSON) rather than zero while `git_email` is still filled in (STAT-13), and the reason is printed to standard error.
|
|
203
221
|
|
|
204
222
|
**Status:** Done
|
|
205
223
|
|
|
@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gitlogstats"
|
|
7
7
|
description = "Track developers' contributions to one or more git repositories within a particular time range."
|
|
8
|
-
version = "1.
|
|
8
|
+
version = "1.4.0"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name="Tobody Tothing", email="nobody.nothing@nowhere.com" },
|
|
11
11
|
]
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
status: Done
|
|
20
20
|
- id: CLI-3
|
|
21
21
|
title: GitHub pull-request statistics
|
|
22
|
-
full:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
full: --github adds GitHub pull-request statistics (STAT-8 to STAT-12),
|
|
23
|
+
contributor emails (STAT-13), pushes to the analyzed branch (STAT-14) and
|
|
24
|
+
website commits (STAT-15) for repositories hosted on github.com, appending
|
|
25
|
+
the columns github_username, prs_opened, prs_merged, prs_closed_unmerged,
|
|
26
|
+
prs_self_merged, git_email, github_email, pushes_to_default, web_commits to
|
|
27
|
+
every output format. Without --github, the output and behaviour are
|
|
28
|
+
unchanged, GitHub is never contacted and the GitHub CLI (gh) is not needed.
|
|
29
|
+
With --github, the GitHub API is called through gh api, so gh must be
|
|
30
|
+
installed and signed in. This is checked before any repository is cloned; if
|
|
31
|
+
it fails, nothing is printed to standard…
|
|
32
32
|
section: §5 Command-Line Interface
|
|
33
33
|
family: CLI
|
|
34
34
|
phase: 1
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
whose commit date falls between the start of the start date and the end of
|
|
40
40
|
the end date, inclusive, in local time. Defaults: one year ago until today.
|
|
41
41
|
The output records the requested start and end dates on every row. With
|
|
42
|
-
--github, each pull request count is filtered by its own timestamp
|
|
43
|
-
same range (CLI-3)."
|
|
42
|
+
--github, each pull request and push count is filtered by its own timestamp
|
|
43
|
+
in the same range (CLI-3)."
|
|
44
44
|
section: §3 Filtering
|
|
45
45
|
family: FILT
|
|
46
46
|
phase: 1
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
title: Remove inactive contributors
|
|
76
76
|
full: By default, contributors with no activity in the date range are listed
|
|
77
77
|
with zeros. -c/--clean removes them. With --github, only rows with neither
|
|
78
|
-
git
|
|
78
|
+
git, pull-request nor push activity are removed (CLI-3).
|
|
79
79
|
section: §3 Filtering
|
|
80
80
|
family: FILT
|
|
81
81
|
phase: 1
|
|
@@ -89,8 +89,9 @@
|
|
|
89
89
|
containing commas, quotes or line breaks are quoted. The header is printed
|
|
90
90
|
even when there are no rows, and the output ends with a single newline. With
|
|
91
91
|
--github, the columns github_username, prs_opened, prs_merged,
|
|
92
|
-
prs_closed_unmerged, prs_self_merged
|
|
93
|
-
|
|
92
|
+
prs_closed_unmerged, prs_self_merged, git_email, github_email,
|
|
93
|
+
pushes_to_default, web_commits are appended, and are in the header even when
|
|
94
|
+
there are no rows (CLI-3).
|
|
94
95
|
section: §4 Output
|
|
95
96
|
family: OUT
|
|
96
97
|
phase: 1
|
|
@@ -348,6 +349,54 @@
|
|
|
348
349
|
family: STAT
|
|
349
350
|
phase: 1
|
|
350
351
|
status: Done
|
|
352
|
+
- id: STAT-13
|
|
353
|
+
title: Contributor email addresses
|
|
354
|
+
full: "With --github, every row also reports the contributor's email addresses
|
|
355
|
+
in two columns appended after prs_self_merged: git_email lists every
|
|
356
|
+
distinct author email of the git identities combined into the row (STAT-11),
|
|
357
|
+
sorted alphabetically (ignoring case) and separated by ; , and is empty for
|
|
358
|
+
a GitHub-only row; github_email is the public email on the matched GitHub
|
|
359
|
+
user's profile, and is empty when the profile has none (GitHub does not
|
|
360
|
+
reveal private emails) or the row has no GitHub user. Emails come from the
|
|
361
|
+
whole history of the analyzed branch, like the contributor list, not only
|
|
362
|
+
from commits in the date range. When GitHub statistics are unavailable for a
|
|
363
|
+
repository (CLI-3), git_email is…"
|
|
364
|
+
section: §2 Contribution Statistics
|
|
365
|
+
family: STAT
|
|
366
|
+
phase: 1
|
|
367
|
+
status: Done
|
|
368
|
+
- id: STAT-14
|
|
369
|
+
title: Pushes to the analyzed branch
|
|
370
|
+
full: "With --github, for each contributor, the number of times they pushed
|
|
371
|
+
directly to the analyzed branch (the default branch, or the -b branch) in
|
|
372
|
+
the date range, reported in a pushes_to_default column appended after
|
|
373
|
+
github_email. Pushes come from GitHub's repository activity record
|
|
374
|
+
(repos/{owner}/{repo}/activity), which names the GitHub user who pushed:
|
|
375
|
+
activity types push and force_push count; pull-request merges, merge-queue
|
|
376
|
+
merges and branch creation or deletion do not. One push counts once however
|
|
377
|
+
many commits it carries. Each push is filtered by its own timestamp, using
|
|
378
|
+
the same inclusive local-time range as FILT-1, and credited to the row of
|
|
379
|
+
the GitHub user who pushed (STAT-11); a GitHub…"
|
|
380
|
+
section: §2 Contribution Statistics
|
|
381
|
+
family: STAT
|
|
382
|
+
phase: 1
|
|
383
|
+
status: Done
|
|
384
|
+
- id: STAT-15
|
|
385
|
+
title: Commits made on the GitHub website
|
|
386
|
+
full: "With --github, for each contributor, how many of their commits counted in
|
|
387
|
+
commits (STAT-1: same date range, exclusions and branch, merges excluded)
|
|
388
|
+
were made on GitHub's website rather than in a local clone, reported in a
|
|
389
|
+
web_commits column appended after pushes_to_default, so web_commits is never
|
|
390
|
+
larger than commits. A commit counts when GitHub created it — its committer
|
|
391
|
+
is GitHub <noreply@github.com> — and it is not the result of merging a pull
|
|
392
|
+
request: a commit GitHub created when squash- or rebase-merging a pull
|
|
393
|
+
request is not a website commit. Such a commit is the merge commit GitHub
|
|
394
|
+
names for a merged pull request, or was committed within 2 seconds of one
|
|
395
|
+
(the other commits of a…"
|
|
396
|
+
section: §2 Contribution Statistics
|
|
397
|
+
family: STAT
|
|
398
|
+
phase: 1
|
|
399
|
+
status: Done
|
|
351
400
|
- id: FUTURE-author-date-filtering
|
|
352
401
|
title: Author-date filtering
|
|
353
402
|
full: Author-date filtering — offer filtering by author date, so rebased or
|
|
@@ -6,7 +6,13 @@ import re
|
|
|
6
6
|
import sys
|
|
7
7
|
from . import GitLogsParser
|
|
8
8
|
from .git_logs_parser import FIELDNAMES
|
|
9
|
-
from .github import
|
|
9
|
+
from .github import (
|
|
10
|
+
ACTIVITY_FIELDNAMES,
|
|
11
|
+
EMAIL_FIELDNAMES,
|
|
12
|
+
GITHUB_FIELDNAMES,
|
|
13
|
+
GitHubUnavailable,
|
|
14
|
+
check_gh,
|
|
15
|
+
)
|
|
10
16
|
from .github_stats import github_rows
|
|
11
17
|
|
|
12
18
|
|
|
@@ -142,7 +148,9 @@ def main():
|
|
|
142
148
|
parser.add_argument(
|
|
143
149
|
"--github",
|
|
144
150
|
help="Also report GitHub pull requests opened, merged, closed and "
|
|
145
|
-
"self-merged per contributor,
|
|
151
|
+
"self-merged per contributor, with their git and GitHub emails, their "
|
|
152
|
+
"pushes to the analyzed branch and their commits made on the GitHub "
|
|
153
|
+
"website, and match GitHub users to git authors. "
|
|
146
154
|
"Needs the GitHub CLI (gh), signed in",
|
|
147
155
|
default=False,
|
|
148
156
|
action="store_true",
|
|
@@ -233,7 +241,11 @@ def main():
|
|
|
233
241
|
# emit a single table (or JSON array) covering all repositories
|
|
234
242
|
if last_parser is not None:
|
|
235
243
|
# an empty CSV table still gets the GitHub columns with --github
|
|
236
|
-
fieldnames =
|
|
244
|
+
fieldnames = (
|
|
245
|
+
FIELDNAMES + GITHUB_FIELDNAMES + EMAIL_FIELDNAMES + ACTIVITY_FIELDNAMES
|
|
246
|
+
if args.github
|
|
247
|
+
else None
|
|
248
|
+
)
|
|
237
249
|
output = last_parser.format_results(all_results, args.format, fieldnames)
|
|
238
250
|
# end with exactly one newline: CSV and Markdown output already has one
|
|
239
251
|
print(output, end="" if output.endswith("\n") else "\n")
|
|
@@ -21,6 +21,11 @@ FILES_RE = re.compile(r"(\d+) files? changed")
|
|
|
21
21
|
INSERTIONS_RE = re.compile(r"(\d+) insertions?\(\+\)")
|
|
22
22
|
DELETIONS_RE = re.compile(r"(\d+) deletions?\(-\)")
|
|
23
23
|
|
|
24
|
+
# STAT-15: the header of each commit when listing who committed it and when
|
|
25
|
+
COMMITTER_LOG_FORMAT = (
|
|
26
|
+
f"--format={RECORD_SEP}%H{FIELD_SEP}%aN{FIELD_SEP}%aE{FIELD_SEP}%cE{FIELD_SEP}%ct"
|
|
27
|
+
)
|
|
28
|
+
|
|
24
29
|
# the fields reported for each contributor, in output order
|
|
25
30
|
FIELDNAMES = [
|
|
26
31
|
"username",
|
|
@@ -128,11 +133,13 @@ class GitLogsParser:
|
|
|
128
133
|
f"--until={until:%Y-%m-%d %H:%M:%S}",
|
|
129
134
|
]
|
|
130
135
|
|
|
131
|
-
def git_log_command(self):
|
|
136
|
+
def git_log_command(self, log_format=LOG_FORMAT, shortstat=True):
|
|
132
137
|
"""
|
|
133
138
|
Build the git log command that lists every non-merge commit in the date
|
|
134
139
|
range with its author and a one-line summary of its changes. Merge
|
|
135
140
|
commits come from merge_log_command instead.
|
|
141
|
+
@param log_format: the --format argument
|
|
142
|
+
@param shortstat: whether to add the summary of changes
|
|
136
143
|
@returns: the command as a list of arguments, ready for subprocess
|
|
137
144
|
"""
|
|
138
145
|
# --full-history stops git from hiding commits while simplifying the
|
|
@@ -142,8 +149,8 @@ class GitLogsParser:
|
|
|
142
149
|
"log",
|
|
143
150
|
"--full-history",
|
|
144
151
|
"--no-merges",
|
|
145
|
-
"--shortstat",
|
|
146
|
-
|
|
152
|
+
*(["--shortstat"] if shortstat else []),
|
|
153
|
+
log_format,
|
|
147
154
|
*self.date_range_args(),
|
|
148
155
|
"--",
|
|
149
156
|
".",
|
|
@@ -185,6 +192,44 @@ class GitLogsParser:
|
|
|
185
192
|
*self.date_range_args(),
|
|
186
193
|
]
|
|
187
194
|
|
|
195
|
+
def current_branch(self):
|
|
196
|
+
"""
|
|
197
|
+
Name the branch checked out in the repository.
|
|
198
|
+
@returns: the branch name, or None if HEAD is detached
|
|
199
|
+
"""
|
|
200
|
+
result = subprocess.run(
|
|
201
|
+
["git", "symbolic-ref", "--short", "-q", "HEAD"], capture_output=True
|
|
202
|
+
)
|
|
203
|
+
if result.returncode != 0:
|
|
204
|
+
return None
|
|
205
|
+
return result.stdout.decode("utf-8", errors="replace").strip()
|
|
206
|
+
|
|
207
|
+
def committed_commits(self):
|
|
208
|
+
"""
|
|
209
|
+
STAT-15: list the commits counted in `commits` (STAT-1: the same date
|
|
210
|
+
range, exclusions and branch, merges left out) with their committers.
|
|
211
|
+
@returns: a list of dicts with hash, name (author), email (author),
|
|
212
|
+
committer_email and committed (committer time, epoch seconds)
|
|
213
|
+
"""
|
|
214
|
+
cmd = self.git_log_command(COMMITTER_LOG_FORMAT, shortstat=False)
|
|
215
|
+
self.verboseprint(f"Running command: {' '.join(cmd)}")
|
|
216
|
+
result = subprocess.run(cmd, capture_output=True, check=True)
|
|
217
|
+
commits = []
|
|
218
|
+
for record in result.stdout.decode("utf-8", errors="replace").split(RECORD_SEP)[
|
|
219
|
+
1:
|
|
220
|
+
]:
|
|
221
|
+
fields = record.strip("\n").split(FIELD_SEP)
|
|
222
|
+
commits.append(
|
|
223
|
+
{
|
|
224
|
+
"hash": fields[0],
|
|
225
|
+
"name": fields[1],
|
|
226
|
+
"email": fields[2],
|
|
227
|
+
"committer_email": fields[3],
|
|
228
|
+
"committed": int(fields[4]),
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
return commits
|
|
232
|
+
|
|
188
233
|
def run_git_log(self, cmd):
|
|
189
234
|
"""
|
|
190
235
|
Run a git log command and parse its output into per-commit records.
|