Import commits per release and create release reports (#1263)

View stats per release, we do this by
doing log diffs between release tags. Ex: `git log
boost-1.78.0..boost-1.79.0`. The output is parsed and the commits
are saved with a foreign key to the `LibraryVersion` it relates to.

- commits are imported by doing "bare" clones (no project files, only
git data) of repos into temporary directories, as created by python's
bulitin `tempfile.TemporaryDirectory`
- Added Commit model
- Added CommitAuthor model
- Added CommitAuthorEmail model
  - One CommitAuthor can have many emails.
- Added task for importing commits. (and admin link to trigger it)
- Added task for importing CommitAuthor github data (avatar and profile
url, with admin link to trigger it)
- Added a basic Library stat page which can be viewed by going to the
admin -> library -> view stats.
- Added a `Get Release Report` button in the `LibraryAdmin` which allows
a staff member to select a boost version and up to 8 libraries to
generate a report for. The report is just a webpage which attempts to
convert cleanly to a pdf using the browser's print to pdf functionality.
- Updated the Library Detail page to show commits per release instead of
per month.
- Updated the Library Detail page to show `Maintainers & Contributors`
sorted by maintainers, then the top contributors for the selected
release, then the top contributors overall by commits descending.
- Removed CommitData, which was tracking monthly commit stats
This commit is contained in:
Brian Perrett
2024-09-25 15:09:07 -07:00
committed by GitHub
parent 6d3e82f8e4
commit 48c09d3d5e
28 changed files with 1435 additions and 452 deletions

View File

@@ -10,7 +10,7 @@
- [`import_library_version_docs_urls`](#import_library_version_docs_urls)
- [`update_maintainers`](#update_maintainers)
- [`update_authors`](#update_authors)
- [`import_commit_counts`](#import_commit_counts)
- [`import_commits`](#import_commits)
- [`import_beta_release`](#import_beta_release)
## `boost_setup`
@@ -209,24 +209,22 @@ If both the `--release` and the `--library-name` are passed, the command will lo
| `--library-name` | string | Name of the library. If passed, the command will load maintainers for only this library. |
## `import_commits`
## `import_commit_counts`
**Purpose**: Saves `CommitData` objects. Each object contains the data for the number of commits made to the `master` branch of a given `Library` with in a given month.
**Purpose**: Cycles through all libraries and their library versions to import `Commit`, `CommitAuthor`, and `CommitAuthorEmail` models. Updates `CommitAuthor` github profile URLs and avatar URLs.
**Example**
```bash
./manage.py import_commit_counts
./manage.py import_commits
```
**Options**
| Options | Format | Description |
|----------------------|--------|--------------------------------------------------------------|
| `--branch` | string | Specify the branch you want to count commits for. Defaults to `master`. |
| `--token` | string | Pass a GitHub API token. If not passed, will use the value in `settings.GITHUB_TOKEN`. |
| `--key` | string | Key of the library. If passed, the command will import commits for only this library. |
| `--clean` | boolean | If passed, will delete all existing commits before importing new ones. |
## `import_beta_release`

View File

@@ -34,7 +34,7 @@ The `boost_setup` command will run all of the processes listed here:
# Save other data we need for Libraries and LibraryVersions
./manage.py update_maintainers
./manage.py update_authors
./manage.py import_commit_counts
./manage.py import_commits
# Get the most recent beta release, and delete old beta releases
./manage.py import_beta_release --delete-versions
@@ -49,7 +49,7 @@ Collectively, this is what these management commands accomplish:
3. `import_library_versions`: Establishes which Boost libraries are included in which Boost versions. That information is stored in `LibraryVersion` objects. This process also stores the link to the version-specific Boost documentation for this library.
4. `update_maintainers`: For each `LibraryVersion`, saves the maintainers as `User` objects and makes sure they are associated with the `LibraryVersion`.
5. `update_authors`: For each `Library`, saves the authors as `User` objects and makes sure they are associated with the `Library`.
6. `import_commit_counts`: For each `Library`, uses information in the GitHub API to save the last 12 months of commit history. One `CommitData` object per library, per month is created to store the number of commits to the `master` branch of that library for that month.
6. `import_commits`: For each `Library`, iterate through the `LibraryVersion`s and create `Commit`, `CommitAuthor`, and `CommitAuthorEmail` objects. Also attempts to update `CommitAuthor`s with their github profile URL and Avatar URL.
7. `import_beta_release`: Retrieves the most recent beta release from GitHub and imports it. If `--delete-versions` is passed, will delete the existing beta releases in the database.
## Further Reading