Project to improve ChangeLog generation.
what it does
- For each package, in portdir:
- Fork AsyncFunction
- Get timestamp of top commit, run:
git log --format=%ct -1 .
- If older than
- Get the list of commits from start of history:
git rev-list HEAD -- .
- For each commit:
- Get changed-files, run:
git diff-tree --name-status --no-renames --format=... --root --relative=$CP_DIR -r $COMMIT -- .
- Parse git output
- Build ChangeLog entry
- Get changed-files, run:
- Combine ChangeLog entries in expected direction (forward or reverse)
Every fork out to git means reading all of the git data structures on disk, and while they will be cached, it's still a lot of work.
analysis of what it does
At the time of writing this, the tree statistics:
- 19225 packages.
- 40039 ebuilds.
- 74625 unique commits.
Running rev-list on each package directory results in
- total of 184773 commits being listed (calling such output pkg-commit for clarity for the rest of this section).
- The 14 commits that touch the most packages account for approximately 50% of all pkg-commits.
- The next most-common 86 commits (such that you get 100 commits in total) only account for a further 8.3% of all pkg-commits.
- There are packages with 300+ commits in their history.
This will happen if there have been no changes between two runs. It still evaluates every single package in PortDB.
- It still evaluates every single package in PortDB.
- Fork for each package.
- Call a single
git-logfor EVERY single package (takes 200+ ms)
With 19000+ packages in the tree, this takes north of 3800 seconds.
This will happen only if there is a global change.
In addition to the best case above, it ALSO does:
git-rev-list(2-4 seconds per package).
git-diff-tree(50ms per commit)
- Commits touching multiple package paths are evaluated MORE than once.
- This makes tree-wide and category-wide commits VERY expensive for ChangeLogs.
- For each commit:
- metadata, message, files-changed
- For each package:
- List of commits
Every commit has 3 timestamps:
- Author time.
- Commit time (implicit by gpg signing time).
- Time first-seen on main tree.
They have two implications:
- What date should be shown on a changelog entry.
- What order should the changelog entries appear in.
In the case of merge commits, author & commit time could be very old, and we would still want the new commit to show up at the top of history if it was added to the main tree after another commit. This either means being aware multiple active paths through git history, or finding another way to imply the ordering of commits.
Additionally, even with regular commits, short of receive-time verification, there's NOTHING enforcing developer clock correctness.
Maybe the BEST solution is for server-side introduction of commit notes, with metadata like when the commit was seen.
- Data-collect phase:
- Run a SINGLE git command
- Should be able to take last-seen commit and only output NEW history
- Output should make it easy to split commits.
- In the worst case, this will output the ENTIRE history; could trivially be restricted (eg by date).
- Parsing phase:
- Split the output of the git command
- populate the commits database
- return a list of changed packages
- Two possible designs
- Pure single-threaded
- For each commit, examine all of the data and split out to data structure
- First part is single-threaded, and just scans for the commit separator.
- Pipe the text of each commit into a separate process that parses & returns data.
- Pre-format the commit messages into the data structure (they can be re-formatted latter, but it will save a lot of future compute)
- Output phase:
- Trivially multi-threaded from this point, needs only reads from the commits data structure.
- For each changed package:
- If most recent commit was a package deletion, delete the ChangeLog file on disk (or stash elsewhere).
- Grab (commit-hash, changetime)
- Sort by changetime
- Write changelog by fetching commits in order.
- write latest hash & changetime to changelog, for ease of validation/processing
- use it to append or prepend new entries.
- Do not trust mtime on changelog file
Git output command
- Format string:
--format='COMMIT%m%n%H %ct %cN <%cE>%n%BFILES%m'
- Needs to be easy to split: between commits, and separate metadata vs list of files & file-actions
- File output:
- No renames:
- Show root as big diff:
- Use topographic order:
git log $FORMAT --name-status --no-renames --root --topo-order
This generates good output, for complete history takes ~10 seconds to generate a 30MiB output.
Topographic order seems mostly correct, but I'm not certain if it remains static as more commits are added.