GitHub - bketelsen/surgeon: Surgically modify a fork

2 min read Original article β†—

Surgeon

Modify your fork of an upstream repository with surgical precision.

See IncusScripts which uses surgeon to modify community-scripts for Proxmox to run on Incus.

Use surgeon to keep your fork up-to-date with an upstream, but make modifications during the process.

For example:

  • use the inject module to add a license or credit to the upstream
  • use the sed module to change a function invocation to a different one
  • use the replacefile module to completely replace a single file

Codemods implement a small-ish interface so it's easy to add new ones. PR's accepted if you find something you need.

type CodeMod interface {
	Apply(source string, target string, match string, args ...string) error
	Validate(source string, target string, match string, args ...string) error
	Description() string
	Usage() string
}

πŸš€ Project Overview

surgeon Modify your fork of an upstream repository with surgical precision.

See IncusScripts which uses surgeon to modify community-scripts for Proxmox to run on Incus.


πŸš€ Known Issues

git push/commit/stage the git commit/push/stage settings don't work correctly. Don't use them yet.


πŸš€ Installation / Usage

See installation documentation


Config

upstream: https://some.repository.com/upstream/repo
stage: true
commit: true
push: false
modsdir: mymods
codemods:
- description: Modify URLS
  mod: sed
  match: cmd/*.go
  args:
  - github.com/upstream/repo
  - github.com/myfork/repo
ignorelist:
- prefix: ct/

See a real world example

IncusScripts uses surgeon as a GitHub Action. See the action

❀️ Community and Contributions

We appreciate any contributions to the projectβ€”whether it's bug reports, feature requests, documentation improvements, or spreading the word. Your involvement helps keep the project alive and sustainable.


🀝 Report a Bug or Feature Request

If you encounter any issues or have suggestions for improvement, file a new issue on our GitHub issues page. You can also submit pull requests with solutions or enhancements!


Star History

Star History Chart


πŸ“œ License

This project is licensed under the MIT License.