Some things to keep in mind when making changes:
- Make the minimal amount of changes
- Avoid refactoring where possible, don't reformat untouched code
- Since we continuously merge in changes from Ormolu, reducing the number of potential conflicts goes a long way towards maintainability of this project.
To release a new version, do the following workflow:
-
Create a new branch
-
Bump version in
fourmolu.cabal
- All version bumps should follow PvP
-
Curate
CHANGELOG.md
, creating a new section for this version and moving everything previously inUnreleased
into the new section (keepingUnreleased
as a section)It should roughly follow this format:
## Fourmolu 1.2.3.0 * Fourmolu-specific change 1 * Fourmolu-specific change 2 ### Upstream changes: #### Ormolu 2.3.4.0 * Ormolu change 1 #### Ormolu 2.3.3.0 * Other change
-
Add comments to new features indicating when it was added (e.g.
@since v2.0.0
) -
Run
stack haddock
orcabal haddock
and skim through documentation
-
-
Create PR as usual and merge into
master
- In the
test_latest
CI job, check the output of thestack sdist
step for any warnings.
- In the
-
Upload the package to Hackage
- Download the
fourmolu-*.tar.gz
file from CI artifacts - Upload tarball to Hackage
- Download the
Fourmolu aims to continue merging upstream changes in Ormolu. Whenever Ormolu makes a new release (ideally within a week), the following steps should be run to merge the changes into Fourmolu.
cd
into your local copy of the Fourmolu repository- Add Ormolu as an upstream remote:
git remote add ormolu git@github.com:tweag/ormolu
- Check out a new branch:
git switch -c merge-ormolu
- Pull Ormolu's git history:
git fetch ormolu --no-tags
- Find the commit corresponding to the new Ormolu version and merge it:
git merge <commit>
- (Recommended) Switch to diff3 conflicts:
git checkout --conflict=diff3
. This provides more context that might be helpful for resolving conflicts. See docs. - Resolve conflicts + finish merge:
git merge --continue
- Rewrite the default commit message to "Merge ormolu-X.Y.Z"
- Run tests to ensure everything works well:
stack test
-
Conflicts at the following paths should be resolved by keeping the files DELETED (i.e. if there's a "deleted by us" conflict, use
git rm
to avoid adding the file to our repo):.github/
.buildkite/
DESIGN.md
default.nix
nix/
shell.nix
-
Conflicts at the following paths should be resolved by throwing out Ormolu's changes and keeping our changes (i.e. if there's a conflict, use
git checkout --ours
):stack.yaml
-
The state of the following paths should be the same as they are in Ormolu (i.e. if there's a conflict, use
git checkout --theirs
)expected-failures/
-
Any Ormolu additions to
CHANGELOG.md
should be added under a### Upstream changes:
header in theUnreleased
section ofCHANGELOG.md
, with the Ormolu headers bumped to####
. See the CHANGELOG format in the "Release a new version" section. -
Be careful when editing
fourmolu.cabal
to only change shared things (e.g.tested-with
) and not Fourmolu things (e.g.name
orversion
).
-
Regenerate test files
- Comment out the line in
PrinterSpec.hs
after the "UNCOMMENT NEXT LINE TO REGENERATE OUTPUT FILES" comment - Run tests and commit any new
*-four-out.hs
files
- Comment out the line in
-
Remove any redundant Fourmolu output files
find data/examples -name '*-four-out.hs' -print0 | while IFS= read -r -d '' f; do dir=$(dirname "$f") name=$(basename "$f" '-four-out.hs') src="${dir}/${name}.hs" if [[ ! -f "$src" ]]; then rm -v "$f" fi done