fix(markdown-format): pre-commit hooks rewrite and lint untouched lines of a staged file

Aberta
#19,208 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
56/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
markdown, shell
Domínio
testing-qa, tooling

Direção de pesquisa

Start with plugins/markdown-format/git-hooks/format.sh and lint.sh, then trace how each hook identifies and processes staged Markdown files. Reproduce the reported behavior with a staged append to a file containing existing formatter drift and MD037 findings. Done means the hooks handle only changed lines or otherwise preserve untouched text while allowing the append to pass.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

needs-owner-decision needs-triage
Steps to reproduce
  1. In a repository that loads lefthook-remote.yml from this repository (melodic-software/architecture does), take a markdown file that already has formatter drift or lint findings on lines nobody is changing. docs/owner-decisions.md has two: rows 49 and 53 contain Bash(git *), which the formatter rewrites, and markdownlint reports MD037 on them.
  2. Append one line to the file, stage it and commit.
Expected behavior

The commit judges only the lines the change touches. An append-only record such as docs/owner-decisions.md can take a new row without its earlier rows changing.

Actual behavior

markdown-format-remote-format (plugins/markdown-format/git-hooks/format.sh) formats the whole staged file and rewrites rows 49 and 53 from Bash(git *) to Bash(git*). markdown-format-remote-lint (plugins/markdown-format/git-hooks/lint.sh) then fails the commit on MD037 in rows that are not part of the change. In melodic-software/architecture#266 the rewrite changed a recorded permission grant in an owner-decision row. A review bot flagged it, and the rows had to be restored by hand in a commit made outside the hook. Skipping the job is not allowed for agents, so an agent cannot append to that file at all.

Severity

Medium

Severity justification

It blocks every agent commit to an append-only record that holds pre-existing drift. The rewrite also silently changes recorded text (a permission string) unless a reviewer notices it. A manual workaround exists (an owner commit), and no data is lost when the rewrite is caught.

Suggested fix location

plugins/markdown-format/git-hooks/format.sh and lint.sh: judge and format only the staged hunks' lines (for example, report lint findings only on changed lines and refuse to rewrite unchanged lines), or let a repository mark files as append-only so that the hooks check only the added lines.

Environment

melodic-software/architecture at bb7e42a with the remote config from claude-code-plugins main; observed 2026-11-25.

Linguagem predominante
Shell
Estrelas
22
Forks
2
Merge médio
2h
PRs com merge (30d)
960

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de melodic-software/claude-code-plugins

Todas as issues de melodic-software/claude-code-plugins

Issues semelhantes

Mais issues de Shell/Bash

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.