Skip to content

Adding git stage support - #65

Merged
perryqh merged 3 commits into
mainfrom
ph.git-stage
Aug 11, 2025
Merged

perryqh merged 3 commits into
mainfrom
ph.git-stage

Conversation

@perryqh

@perryqh perryqh commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Matches https://github.com/rubyatscale/code_ownership support for staging the CODEOWNERSHIP file after generation

@jackboberg jackboberg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved as is, but should there be a test for not staging the file?

@perryqh
perryqh merged commit e788e3d into main Aug 11, 2025
@github-project-automation github-project-automation Bot moved this from Triage to Done in Modularity Aug 11, 2025
dduugg added a commit to rubyatscale/code_ownership that referenced this pull request Oct 21, 2026
* Fix inverted stage_changes in CodeOwnership.validate!

validate! is documented to stage the regenerated .github/CODEOWNERS by
default and to leave it unstaged with stage_changes: false, which is
what bin/codeownership validate --skip-stage passes. It did the
opposite.

validate! passed !stage_changes to the extension, whose
generate_and_validate took it as skip_stage, as the RBI declared, but
handed it unchanged to codeowners-rs's runner::generate_and_validate,
whose third parameter is git_stage. That has been the case since the
extension was added in #126: the codeowners-rs it pinned already took
git_stage (rubyatscale/codeowners-rs#65). codeowners-rs ignores the
result of its git add, so nothing ever failed.

Pass stage_changes through, and rename the extension's parameter and
the RBI's to git_stage to match codeowners-rs, so the flag means the
same thing at every layer. The extension's behavior is unchanged, so
the tracked bundle needs no rebuild: the fix works with it as
committed, and the specs that call
RustCodeOwners.generate_and_validate(nil, false) to write a CODEOWNERS
file still don't stage it.

Add specs that validate! stages CODEOWNERS by default in a git
repository and leaves it unstaged with stage_changes: false. Both fail
without the fix. They clear git's repo-local environment variables
first, so a run from a hook or a linked worktree can't stage into the
enclosing repository. The CLI specs only check the arguments that
reach validate!, so nothing covered what it does to the index.

Add a regression guard for an empty package.yml.
rubyatscale/codeowners-rs#142 moves YAML parsing to serde-saphyr, whose
unreleased 2.1.0 no longer reads a null document as an empty struct
(the fix for bourumir-wyngs/serde-saphyr#233). That PR reads
package.yml as an Option so an empty file still means no owner. The
spec covers an empty file, a comment-only file and a bare "---".
validate! raises if such a file fails to parse, while for_file only
prints the error and falls back to the file's annotation, so the spec
also checks that for_file prints nothing. It passes today.

* Bump version to 2.2.1

* Clear git's repo-local env vars for the whole suite

The fix makes every real validate! call with default arguments run git
add, not only the new staging specs. Two cli_spec examples do that, and
under a hook's GIT_DIR they staged .github/CODEOWNERS into the enclosing
repository, since the scrub only wrapped the staging context. Move it
to a before(:suite) hook so every example's git runs against its own
temp project.

Split the empty package.yml example in two, so validation and the
for_file parse-error check pass or fail separately, without nesting
one expect inside another.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants