Skip to content

Implement --force#478

Merged
DavisVaughan merged 5 commits intomainfrom
feature/force
Mar 13, 2026
Merged

Implement --force#478
DavisVaughan merged 5 commits intomainfrom
feature/force

Conversation

@DavisVaughan
Copy link
Collaborator

@DavisVaughan DavisVaughan commented Mar 9, 2026

Branched from #476, this is a follow up to that PR to add back a way to --force formatting on command line provided files and folders, regardless of exclusion patterns and inclusion patterns

# Formats cpp11.R even though it matches an `default-exclude`
air format cpp11.R --force

# Formats r-code.txt even though it does not match a `default-include`
air format r-code.txt --force

# Recursively format all files (regardless of file type) in folder/, regardless of exclusions and inclusions
# (dangerous!)
air format folder/ --force 

With this PR, the "unsafe" thing becomes opt in, which feels right.


Note that --force only applies to exclude, default-exclude, and our internal default-include patterns. It does not apply to our .gitignore support because that's already a little complicated. We unconditionally respect your .gitignore, but due to the way the ignore Rust crate works, if you do air format git-ignored.R then it will format that regardless because the ignore crate author thinks that a user supplied file should always count, regardless of the .gitignore. I think that is much less of an issue compared to #476, because pre-commit knows to never call hooks on gitignored files, and it seems very unlikely that RStudio would ever do this. I'm not super worried about this, especially since we don't expose any way to turn off gitignore support anyways.

Copy link
Collaborator

@lionel- lionel- left a comment

Choose a reason for hiding this comment

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

Probably worth calling out the gitignore behaviour in the clap doc. I mostly use the LSP, but if I was a CLI user it'd affect me because I have gitignored folders containing scratch R files in my R projects.

@DavisVaughan DavisVaughan force-pushed the feature/respect-exclude-include branch 2 times, most recently from 1b6e414 to 3978563 Compare March 13, 2026 17:08
@DavisVaughan DavisVaughan force-pushed the feature/respect-exclude-include branch from 3978563 to 5ce43e4 Compare March 13, 2026 17:25
Base automatically changed from feature/respect-exclude-include to main March 13, 2026 17:29
@DavisVaughan DavisVaughan merged commit a315ad8 into main Mar 13, 2026
6 checks passed
@DavisVaughan DavisVaughan deleted the feature/force branch March 13, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants