Skip to content

feat(run): warn instead of error when --files is used outside a git repo#3650

Closed
vmandela wants to merge 1 commit intopre-commit:mainfrom
vmandela:support_running_outside_git_worktree
Closed

feat(run): warn instead of error when --files is used outside a git repo#3650
vmandela wants to merge 1 commit intopre-commit:mainfrom
vmandela:support_running_outside_git_worktree

Conversation

@vmandela
Copy link
Copy Markdown

@vmandela vmandela commented Apr 5, 2026

When pre-commit run --files <files> is called outside a git repository, the tool previously raised a FatalError and exited with code 1.

  • Print a warning that pre-commit is running outside a git repository and only the explicitly passed files will be checked
  • Continue execution rather than aborting
  • All other commands (and run without --files) retain the existing fatal error behavior

This modification helps use pre-commit in jujutsu worktrees as long as the modified file list is supplied on command line.

When `pre-commit run --files <files>` is called outside a git
repository, the tool previously raised a FatalError and exited
with code 1.

- Print a warning that pre-commit is running outside a git
  repository and only the explicitly passed files will be checked
- Continue execution rather than aborting
- All other commands (and `run` without `--files`) retain the
  existing fatal error behavior

This modification helps use pre-commit in jujutsu worktrees as long
as the modified file list is supplied on command line.

Signed-off-by: Venkateswara Rao Mandela <[email protected]>
@asottile
Copy link
Copy Markdown
Member

asottile commented Apr 5, 2026

even with --files pre-commit must cd to the repo root

@asottile asottile closed this Apr 5, 2026
@vmandela
Copy link
Copy Markdown
Author

vmandela commented Apr 5, 2026

I have run this for jj workspace root and it functions without issues. Can you explain what you mean by "even with --files pre-commit must cd to the repo root" ?

@asottile
Copy link
Copy Markdown
Member

asottile commented Apr 5, 2026

the line you're skipping at the end of the function. also if you search the tracker there's already an extensive conversation specifically about this

@vmandela
Copy link
Copy Markdown
Author

vmandela commented Apr 5, 2026

I found the old discussions on this topic. Lets leave the PR closed.

This functionality is quite useful to me as I use jj worktrees with a main repo versioned in git. I will keep this in my branch.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants