README excerpt
# Baseliner
A Pharo tool for Metacello baselines (`BaselineOf` classes). It does two jobs:
1. **Edit a baseline**: read it, check it against Metacello's rules and against the code of its packages, and fix
what is wrong, each change previewed before it is applied.
2. **Release a project with its dependencies**: see which of the projects it depends on have commits after their
latest tag, tag them, and pin the new tags in the baselines that load them, bottom-up.
## Installation
In Pharo 15:
```smalltalk
Metacello new
baseline: 'NewToolsBaseliner';
repository: 'github://pharo-spec/NewTools-Baseliner:master/src';
load.
```
Groups: `Core` (the model, without UI), `UI`, `Tests`, and `default` (all of them).
## Scenario 1: editing a baseline

Open the Baseliner on a baseline of the image:
```smalltalk
StBaselinerPresenter openOnClass: BaselineOfMyProject.
```
or try it on a small baseline with one problem of most kinds:
```smalltalk
StBaselinerPresenter exampleWithProblems.
```
**Open...** chooses another `BaselineOf` class of the image; **From file...** reads a Tonel file
(`BaselineOfFoo.class.st`) of a baseline that is not loaded.
### Read
- The drop list selects a **profile**: a platform the baseline mentions (`pharo15`, `gemstone`...). The tree on the
left shows the projects, packages and groups the baseline declares for that profile.
- Selecting an element shows its details (its repository, what it requires, where it is declared) and selects its
declaration in the source.
### Check
The findings at the bottom come from all the profiles at once, errors first, under a summary line. Selecting a
finding selects its code. **Validate** checks the baseline again.
- **Level 1, inside the baseline**: undeclared names, cycles of requirements, empty groups, a name declared as two
kinds of spec, a doit the baseline does not implement, obsolete Metacello messages (`author:`, `blessing:`...),
projects not pinned to a version, constructs the Baseliner can read but not change.
- **Level 2, against the code** (check **Vs Image**, for a project loaded in the image): a package that uses another
one without requiring it, or requires it only indirectly; a requirement its code does not use; a package declared
but missing from the repository; a package of the repository the baseline never declares.
### Fix
Every change is a transformation, shown as a diff of the methods it changes, applied only when accepted.
- The context menu of a **finding** offers its fixes: add the missing requirement, remove the empty group, drop the
obsolete message, declare the forgotten package...
- The context menu of an **element** of the tree offers the edits: add, remove or rename a package; add or remove a
requirement, a group, a group member or a project; change the repository or the loads of a project.
- Edits keep the layout and the comments of the baseline: only the changed expressions are rewritten. They go into
every place the element is declared, including the helper methods `baseline:` calls.
- **Undo** takes back the last change.
### Save
**Save** shows the diff of every method changed since the baseline was read, and writes them back to the class or the
file it came from. A baseline with errors is saved only after a warning ("Save anyway").
## Scenario 2: releasing a project and its dependencies

Open the release window on a baseline whose repository is cloned in Iceberg:
```smalltalk
StBaselinerReleasePresenter openOnClass: BaselineOfBloc.
```
It is also the **Release...** button of the Baseliner, and **Open...** in the release window chooses another
baseline. To see the window without touching any repository, try it on recorded repositories:
```smalltalk
StBaselinerReleasePresenter exampleRecorded.
```
### Read the tree
Opening the window fetches every repository of the tree, and clones the missing ones, as Metacello would to load
them. **Refresh** does it again. Each row is a project, under the projects that depend on it, with:
- **State** and **Details**: whether it can be released and, when not, why and what to do;
- **Latest tag**: its highest `vX.Y.Z` tag, and **Commits**: the number of commits after it;
- below, for the selected project: the full reason, its repository as its parents pin it, who depends on it, and the
subject lines of its commits after the latest tag, to help choose the next version.
The states:
| State | Meaning |
| --- | --- |
| up to date | no commit after its latest tag: nothing to release |
| needs release | commits after its latest tag, and everything ready to tag it: the only state that can be selected |
| not ready | its clone cannot be tagged now: no branch checked out, changes of the image not committed, commits not pushed, no clone, or a failed clone or fetch |
| behind | its remote has commits its clone has not: pull first |
| read only | it needs a release, but you may not push to its GitHub repository |
| has errors | its baseline has Baseliner errors (level 1) |
| not supported yet | not a well-behaved project (below): its parents keep their pin on it |
The reason always says what to change, naming the baseline to edit. In the picture, the clones of Bloc, Alexandrie and
XMLParser have no branch checked out (Bloc's is on its tag v3.1.0), so they cannot be tagged now: check out their
branch in Iceberg. The dependencies of XMLParser are not supported: `BaselineOfXMLParser` pins some of them to tags
such as `v1.2.x`, which are not of the form `vX.Y.Z`, and declares the others otherwise than with
`spec baseline: '...' with: [ ... ]`.
### Choose and release
1. Check the **Release** box of the projects to release.
2. Give each one its **new tag**: type it, or take the next **Patch** (the default), **Minor** or **Major** version
of its latest tag. A tag that is not `vX.Y.Z`, that exists already, or that is not after the latest one is
refused, with the reason under it.
3. **Plan...** shows every step the release would make, in order, without making any.
4. **Release...** shows the plan again and, once accepted, runs it bottom-up. For each project selected: pin its
dependencies released to their new tags in its baseline, commit, push, tag, push the tag. The root, when not
selected, only gets its baseline pinned and committed.
The release stops at the first step that fails and reports what was done, what failed and why, and what was not
done. What was pushed stays pushed.
### Well-behaved projects
For now, the release handles only projects that are:
1. on GitHub, declared with `spec baseline: 'X' with: [ spec repository: 'github://owner/repo:vX.Y.Z/path' ]`, the
repository a literal string, the same in every declaration and in every parent;
2. pinned to a `vX.Y.Z` tag, not to a branch;
3. tagged `vX.Y.Z`: other tags that look like versions are ignored when they are below the latest `vX.Y.Z` tag
(`v0.10` next to `v3.1.0`), and refused above it;
4. free of Baseliner errors.
Push rights are asked to GitHub with your Iceberg credentials. When they cannot be known, the project can still be
released, with a warning: the push will tell.
## Design
The design and its history are in [PLAN.md](PLAN.md); the release is its section 13. The class comments of
`StBaselinerPresenter`, `BslReleaseTree` (with the 21 checks of a project, in order) and `BslReleasePlan` describe
the architecture.
## Packages
| Package | Content |
| --- | --- |
| `NewTools-Baseliner-Core` | the baseline document, read from a class or a Tonel file without installing it, profiles, saving |
| `NewTools-Baseliner-Validation` | the checks of levels 1 and 2 and their findings |
| `NewTools-Baseliner-Transformations` | the edits, as transformations of the source |
| `NewTools-Baseliner-Release` | the release tree, plan and runner, and the access to git and GitHub through Iceberg |
| `NewTools-Baseliner-UI` | the Baseliner and release windows |
Each has its `-Tests` package. The release tests never touch the network nor your repositories: they use recorded
repositories, or local git repositories in a temporary directory.
## License
MIT, see [LICENSE](LICENSE).