Skip to content

Commit

Permalink
fix(doc): Add fastmod --hidden to mass-renames.md (#6913)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
teor2345 and mergify[bot] authored Jun 15, 2023
1 parent dc1eb18 commit 98478c3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions book/src/dev/mass-renames.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
```

Expand 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:
Expand Down

0 comments on commit 98478c3

Please sign in to comment.