---
slug: moon-v1.9
title: moon v1.9 - VCS hooks management and improved task inheritance
authors: [milesj]
tags: [vcs, git, hooks, task, inheritance]
image: ./img/moon/v1.9.png
---

In this release, we're introducing a long requested feature, VCS hooks! As well as a complete
rewrite of our task inheritance layer.

<!--truncate-->

## Support for VCS hooks

In our last release, we added support for [code ownership](./moon-v1.8), to better help teams manage
their code review and approval workflows. To continue this trend of "features all companies require
but don't have a good solution for", we're adding support for VCS hooks,
[starting with Git](https://git-scm.com/docs/githooks).

If you're unfamiliar with Git hooks, they're a mechanism for running scripts before or after certain
Git events. For example, before a commit is added, before pushing, or after merging. Hooks can be
used for such situations as:

- Ensuring commit messages abide by a certain format.
- Ensuring affected project's source code pass linting and formatting checks.
- Validating configuration files.
- And much more!

:::info

For more information, view our official in-depth [VCS hooks guide](/docs/guides/vcs-hooks)!

:::

### New `vcs` settings

To support hooks, we're introducing the `vcs.hooks` and `vcs.syncHooks` settings to
[`.moon/workspace.yml`](/docs/config/workspace). The former is where you configure the list of
commands to run, grouped by hook type.

```yaml title=".moon/workspace.yml"
vcs:
  hooks:
    pre-commit:
      - 'pre-commit run'
      - 'moon run :lint --affected'
```

The latter will automatically create and sync hooks with the local VCS checkout, enabling them going
forward. [Learn more about enabling hooks](/docs/guides/vcs-hooks#enabling-hooks), and choosing the
approach that works best for you or your team!

### New `moon sync hooks` command

Although moon can [automatically create](/docs/config/workspace#synchooks) hooks when running a
target, this may be undesirable or abrasive for some developers. Instead, we also support an opt-in
solution through the [`moon sync hooks`](/docs/commands/sync/vcs-hooks) command, which will manually
create the hooks.

```shell
$ moon sync hooks
```

## Rewritten task inheritance

One of the most complicated systems in moon is the task inheritance layer. On the surface, it sounds
rather simple, but internally it was very complicated. For common use cases, it worked very well,
but for advanced use cases, how a task was "inherited and merged" was sometimes undefined behavior.

Over the past year, we've introduced many new features, such as
[implicit dependencies and inputs](./v0.23), [tag-based task inheritance](./moon-v1.2),
[project-level environment variables](./v0.23#project-level-environment-variables),
[custom languages](./v0.25#custom-project-language) and
[platforms](./v0.24#project-level-task-platform), and so much more. Each of these new features would
throw yet another facet to be aware of during the task inheritance model, and over the past year, it
has become rather unwieldy.

To rectify this situation before it becomes worse, we rewrote our
[project, task](https://github.com/moonrepo/moon/pull/921), and
[task inheritance](https://github.com/moonrepo/moon/pull/939) layers from the ground-up using a new
builder pattern, including writing all new unit tests, to properly and efficiently account for all
edge cases.

Going forward, tasks should be far more accurate and deterministic. If you encounter any weirdness,
it's either a bug/edge case that was rectified (and is no longer allowed), or a bug/edge case not
accounted for in our current unit test suite. Please report them either way!

## Other changes

View the [official release](https://github.com/moonrepo/moon/releases/tag/v1.9.0) for a full list of
changes.

- Added `--clean` and `--force` flags to `moon sync codeowners` command.
- Updated `moon init` to detect VCS providers and resolve fully-qualified tool versions.
- Improved VCS file handling, caching, and performance.
