Skip to content

Campaigns tutorial: search & replace specific terms

Warren Gifford requested to merge mrn-tutorial-replace-language into main

Created by: mrnugget

This adds a tutorial to the campaigns docs that shows how to replace "whitelist" & "blacklist" with "allowlist" & "denylist" in Markdown files.

As you can see I decided against using the templated-campaigns-spec prototype for this, since it's not merged yet and not released and the experimental features aren't documented yet. Instead I wrote two campaign specs (one using sed, one using ruplacer) that can be run with the current Sourcegraph and src-cli versions.

I also decided to only run this over Markdown files to demonstrate how to do filtering of files — in the repositoriesMatchingQuery and in steps.Run — and since search & replacing such common terms across code files, config files, JSON files, etc. is simply not valuable because it breaks a ton of stuff and basically every occurrence needs to be manually confirmed.

Edit:

Once the prototype is merged I want to extend this tutorial to show how to only search & replace in specific files yielded by the search.

image

Merge request reports

Loading