- Introduction
- The parts
- Where the diff comes from
- Internal repositories
- Secrets in the diff
- Options
- How the manipulators apply the alignment
- Project version
Introduction
During alignment PNC (through Reqour) runs a manipulator on the upstream sources and commits the result on top of
the original revision. bacon pnc build get-alignment-diff captures those changes as a diff that applies on top of
the original upstream sources, so that the PNC build can be reproduced or reviewed elsewhere.
bacon pnc build get-alignment-diff BRJO2LNIL6QAA
The parts
The diff is split into up to four files, numbered in apply order. Only the files with changes are written.
| File | Required | Content |
|---|---|---|
*-1-build.diff |
yes | The alignment itself: dependency, plugin and property changes, project version rewrites, generated files, anything not recognized |
*-2-rerun-state.diff |
yes for Gradle/sbt | GME/SMEG files that apply the alignment at build time (see below) |
*-3-reproduce.diff |
no | Removed repositories, to match the PNC build exactly |
*-4-noise.diff |
no | PME marker, build output the project does not ignore, PME stamp, reports and backups, formatting-only changes: never affects the build |
Every part applies on its own on top of the upstream sources; applying all of them, in any order, reproduces the complete alignment. Applying them in numeric order is recommended:
git apply BRJO2LNIL6QAA-alignment-1-build.diff BRJO2LNIL6QAA-alignment-2-rerun-state.diff
Each file starts with comments describing its content, when it can be skipped, the project and its version change. A
file grouping several categories has one commented section per category. The comments also list the removed
repositories, the added files no rule recognized (kept in the build part) and any warning; git apply and patch
ignore them.
The reproduce part only holds the repositories PNC removed from the pom.xml files, so that the build resolves from
the PNC repository only. Apply it to reproduce the PNC build exactly; skip it when building outside PNC, where the
removed repositories may still be needed to resolve the dependencies.
Where the diff comes from
The diff is read from the internal repository, either directly from the git provider (GitHub, GitHub Enterprise or
GitLab) or through PNC, chosen with scmSource in the active profile (the same setting applies to the build sources):
scmSource |
Source |
|---|---|
auto (default) |
The git provider, then PNC when the git provider fails or cannot be reached |
direct |
The git provider only, with the profile’s githubToken or gitlabToken |
orch |
PNC only (/builds/<id>/alignment-diff and /builds/<id>/scm-archive/content): PNC reads the repository through Reqour, so no access to the git provider and no git provider token are needed, only to PNC |
- name: "default"
scmSource: orch
Through PNC, the profile’s PNC login is needed (keycloak or ldapUsernamePassword): PNC passes it on to Reqour,
which checks it again, so the account needs a role that may read builds in both. When PNC answers that it is busy, or
that the git provider is rate-limiting it, the request is retried once if PNC asks to wait at most a minute; otherwise
the error says how long to wait.
Through PNC, and directly from GitLab, binary files and files too large for the provider’s diff are included as git
binary patches; directly from GitHub they stay Binary files ... differ. When the pre-alignment revision is not an
ancestor of the aligned commit, the diff of the aligned commit against its parent is used instead, with a warning.
Internal repositories
The diff is read from the build’s internal repository on GitHub or GitLab (see
the configuration guide for the tokens). GitLab does
not return binary files, nor patches over its size limit, in a diff: bacon reads those files through the raw file API
and writes them as text hunks or GIT binary patch blocks, so the parts still apply. Files that cannot be read, larger
than 100 MiB, or read after 512 MiB of such files for the same diff, stay as Binary files ... differ and are listed in
a warning; they cannot be applied from the diff.
Secrets in the diff
Known credentials are masked only in the metadata files the manipulators write (reports such as
alignmentReport.json and manipulation.json, and their backups), so that the source and build files stay
byte-exact and the diff applies. A secret committed in a source or build file of the repository appears in the diff
as it is. Review the diff before sharing it outside the people who can read the internal repository.
Options
--output <file>: the base name of the part files,<build ID>-alignment.diffby default. The parts are named after it, e.g.--output out/widget.diffwritesout/widget-1-build.diff,out/widget-3-reproduce.diff, …--manifest: also writes<base name>-manifest.json, describing the split for review or tooling. It is not needed to apply the parts. It contains:project: the project identifier, as on the# Project:line (see below);alignedVersions: the aligned versions of the project’s own modules, used to recognize the project version rewrites, read from the alignment reports in the diff or from the PNC build;alignedProjects: the modules of the project recorded by the alignment reports, with theirgroupId,artifactId,originalVersionandalignedVersion(SMEG only records the aligned version);alignedDependencies: the dependencies and plugins recorded as aligned by the PME and GME reports, with theirtype(dependency,plugin,managed-dependencyormanaged-plugin),groupId,artifactId,originalVersion,alignedVersionand themoduleswhere they were aligned. PME writes its report undertarget/, so it is only in the diff, and in this list, when the project does not ignoretarget/;parts: per category, the part number and file, whether it is present and required, and the same descriptions as the comments;summary: the number of files and changes per category;files: every changed file with its status and, for the whole file or for each hunk, the category and the rule that chose it (e.g.aligned-versionfor a project version rewrite andalignmentfor the other changes, both in the build part);removedRepositories: the kind (repositoryorpluginRepository), id, url and file of every removed repository;projectVersions: the project version changes, with the files holding them;unrecognizedAddedFilesandwarnings.
How the manipulators apply the alignment
The manipulators apply the alignment in two different ways, which is why the rerun-state part mentions GME and SMEG but not PME:
- PME (Maven) rewrites the
pom.xmlfiles directly. The aligned dependency, plugin and property versions are plain edits of the POMs, and so is the project version rewrite: they all land in the build part. PME leaves nothing behind that the build needs: its leftovers are the marker (target/pom-manip-ext-marker.txt, which makes a later PME run skip the alignment), the stamp comment appended to the POMs and thetarget/manipulation.jsonreport, all in the noise part. These files reach the alignment commit only when the project does not ignoretarget/(old tags often have no.gitignore); any other new file a build left undertarget/,.gradle/or a Gradle project’sbuild/then goes to the noise part too (categorybuild-output). - GME (Gradle) and SMEG (sbt) mostly do not rewrite the build files. GME writes
manipulation.json, copiesgme.gradle(andgme-pluginconfigs.gradle,gradle/gme-repos.gradle) and injectsapply fromlines into the build files to load them; at build time the GME plugin reads the aligned versions frommanipulation.json. SMEG does the same throughmanipulations.sbt, which sbt loads automatically. For these, the rerun-state part effectively is the alignment.
So PME changes never go to the rerun-state part: it is required for Gradle/sbt builds and simply absent for Maven builds. Leave it out only when running GME/SMEG again yourself, as they must start from the upstream state.
Project version
The project version change is reported in the same way whatever the manipulator, on a
# Project version: <original> -> <aligned> line at the top of every part, and in the command output. The files
holding it are listed in the manifest (--manifest). It is preceded by a # Project: <groupId>:<artifactId> line
identifying the project: the root module recorded by the alignment report in the diff (the PME execution root, the
GME root project), else the name PNC gave the build (its BREW_BUILD_NAME attribute), else unknown. The project
version is read from:
| Manipulator | Source | Part holding the change |
|---|---|---|
| PME | the version rewritten in the pom.xml files |
build |
| GME | originalVersion and version in manipulation.json |
rerun-state |
| SMEG | version := in manipulations.sbt (the original version is not recorded) |
rerun-state |
The project version change is part of the alignment whatever the manipulator, and is never optional: a project often uses its own version elsewhere (e.g. a property referencing its sibling modules), which the manipulator aligns together with the other properties, so the build part does not build without the version rewrite.