Skip to content

Update ocamlformat to 0.18.0

Context

Update to recent ocamlformat.

HOW TO: Rebasing an MR

  • Prerequisites:

    • make sure your local master is up to date

      git checkout master
      git pull
    • switch back to your branch

      git checkout your-branch-for-some-feature
    • back-up your branch by pushing it. You'll be able to refer to your saved branch with the ref @{u} from there on.

      git push
    • make sure your repository is clean. The following command should say "nothing to commit, working tree clean"

      git status -u
  1. Your branch, up to this MR

    • Rebase your branch normally up to the point just before the introduction of the ocamlformat weirdness. You'll have to deal with conflicts normally here.

      NOTE: This is a normal rebase, identical to usual rebases that you have to perform against master occasionally during development. The only difference is that you are passing a commit hash as an argument rather than a branch name. If you have any questions about that, don't hesitate to ask for help on slack.

      git rebase b782e6b59d69ca243d94860c31cea65254a988c3
  2. Your branch through this MR

    • Get the ocamlformat commits but ignore conflicts (your modifications will be incorrectly formatted at this step, we'll fix it later). (Note: git has a joke about ours/theirs commits during rebase, this is the command you want!)

      git rebase b483ada5d9abfe90ecb40b68a3ce7c5b3711483a --strategy recursive --strategy-option theirs
    • Update your dependencies, amongst which is ocamlformat (you won't need to do that for the next MR that you rebase this way, your environment then should be all set).

      make build-dev-deps
    • Check that you have the expected version of ocamlformat. The following command should say 0.18.0.

      ocamlformat --version
    • In-place modify your commits by formatting the code in them.

      git rebase \
          --exec "make fmt-ocaml || true && git add . && git commit --amend --no-edit" \
          --strategy recursive --strategy-option theirs \
          b483ada5d9abfe90ecb40b68a3ce7c5b3711483a
  3. If your branch does not modify tezt/lib or tezt/lib_tezos, you can skip to step 4. Otherwise, you will probably get conflicts if you try to rebase on master. If fixing them manually is too tedious, you can repeat steps 1 and 2 to get around another ocamlformat commit as follows:

git rebase 02e69554b92b3b6960de3392326bb4f85c80d7f5
git rebase fe0e098d23f72b58fa7211134a731f252b851168 --strategy recursive --strategy-option theirs
git rebase \
    --exec "make fmt-ocaml || true && git add . && git commit --amend --no-edit" \
    --strategy recursive --strategy-option theirs \
    fe0e098d23f72b58fa7211134a731f252b851168
  1. Your branch beyond this MR

    • Now just catch up with master via a normal rebase

      NOTE: This is a normal rebase, identical to usual rebases that you have to perform against master occasionally during development. If you have any questions about that, don't hesitate to ask for help on slack.

      git rebase master

Failure modes:

  • You have introduced a new .ocamlformat? Restart the procedure (git reset --hard @{u} resets your current branch to the online saved state) but before you do any rebasing, amend your commits to get master's .ocamlformat` files copied where you have the new ones. Don't hesitate to ask for help on slack.
  • You have modified the Makefile, the tooling, something else? Ask for help on slack and we can work through it all.

Manually testing the MR

make build-dev-deps
make fmt

Reviewers

@pirbo @abate @smondet who have all contributed to previous setup of ocamlformat and such.

Edited by Romain

Merge request reports