fix(doc): Add `fastmod --hidden` to mass-renames.md (#6913)

* Add `fastmod --hidden` to mass-renames.md

* Do multiple skip paths

* Do multiple sed renames in the same sed

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
teor 2023-06-16 04:35:44 +10:00 committed by GitHub
parent dc1eb18aaf
commit 98478c3b75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 5 deletions

View File

@ -13,14 +13,14 @@ so changing them can lead to unexpected test failures or hangs.
You can use `sed` to rename all the instances of a name in Zebra's code, documentation, and tests:
```sh
git ls-tree --full-tree -r --name-only HEAD | \
xargs sed -i 's/OldName/NewName/g'
xargs sed -i -e 's/OldName/NewName/g' -e 's/OtherOldName/OtherNewName/g'
```
Or excluding specific paths:
```sh
git ls-tree --full-tree -r --name-only HEAD | \
grep -v 'path-to-skip' | \
xargs sed -i 's/OldName/NewName/g'
grep -v -e 'path-to-skip' -e 'other-path-to-skip' | \
xargs sed -i -e 's/OldName/NewName/g' -e 's/OtherOldName/OtherNewName/g'
```
`sed` also supports regular expressions to replace a pattern with another pattern.
@ -47,7 +47,8 @@ git worktree add ../zebra-pr origin/pr-branch-name
cd ../zebra-sed
# run the scripts in the PR or commit message
git ls-tree --full-tree -r --name-only HEAD | \
xargs sed -i 's/OldName/NewName/g'
grep -v -e 'path-to-skip' -e 'other-path-to-skip' | \
xargs sed -i -e 's/OldName/NewName/g' -e 's/OtherOldName/OtherNewName/g'
cargo fmt --all
```
@ -66,9 +67,11 @@ and ask the author to re-run the script on the latest `main`.
You can use `fastmod` to rename some instances, but skip others:
```sh
fastmod --fixed-strings "OldName" "NewName" [paths to change]
fastmod --hidden --fixed-strings "OldName" "NewName" [paths to change]
```
Using the `--hidden` flag does renames in `.github` workflows, issue templates, and other configs.
`fastmod` also supports regular expressions to replace a pattern with another pattern.
Here's how to make a PR with these replacements: