title: Can I exclude files from every pre-commit hook except for one without repeating myself?
body: <p>I would like to make a Git repo that’s <a href="https://reuse.software/" rel="noreferrer">REUSE</a> compliant. I want to use <a href="https://github.com/fsfe/reuse-tool#run-as-pre-commit-hook" rel="noreferrer">the reuse pre-commit hook</a> to help ensure that I’m compliant. <a href="https://reuse.software/spec/" rel="noreferrer">The REUSE Specification</a> requires that I make a folder called “LICENSES” that contains each of the licenses that my project uses. I’m using several other hooks, and I don’t want those hooks to check or modify anything in the <code>LICENSES/</code> folder. I want every hook other than reuse to exclude <code>LICENSES/</code>. (Side note: at the moment, it looks like the reuse hook isn’t affected by excluding <code>LICENSES/</code>, but that should probably be fixed). Here’s what I’ve tried so far:</p>
  <pre><code>exclude: '^LICENSES/'
  repos:
      -
          repo: https://github.com/pre-commit/pre-commit-hooks
          rev: v4.0.1
          hooks:
              - id: check-case-conflict
              - id: end-of-file-fixer
              - id: mixed-line-ending
              - id: trailing-whitespace
      # I’m using identity instead of reuse here for testing and to better
      # illustrate the problem.
      -
          repo: meta
          hooks:
              -
                  id: identity
                  exclude: &quot;^$&quot;
  </code></pre>
  <p>That didn’t work. It looks like the per-hook exclude pattern applies in addition to the global one. I wanted the per-hook exclude pattern to apply instead of the global one.</p>
  <p>I could use a per-hook exclude pattern on every hook except one:</p>
  <pre><code>repos:
      -
          repo: https://github.com/pre-commit/pre-commit-hooks
          rev: v4.0.1
          hooks:
              -
                  id: check-case-conflict
                  exclude: &amp;exclude_pattern '^LICENSES/'
              -
                  id: end-of-file-fixer
                  exclude: *exclude_pattern
              -
                  id: mixed-line-ending
                  exclude: *exclude_pattern
              -
                  id: trailing-whitespace
                  exclude: *exclude_pattern
      # I’m using identity instead of reuse here for testing and to better
      # illustrate the problem.
      -
          repo: meta
          hooks:
              - id: identity
  </code></pre>
  <p>But, then I would be repeating myself. I think that I might be able to repeat myself less using merge keys, but <a href="https://ktomk.github.io/writing/yaml-anchor-alias-and-merge-key.html" rel="noreferrer">I don’t think that those are supported</a>. Is there anyway to avoid repeating myself or to repeat myself less?</p>