{"id":21710673,"url":"https://github.com/mbrav/gitraider","last_synced_at":"2025-05-13T02:53:51.299Z","repository":{"id":149790598,"uuid":"619324878","full_name":"mbrav/gitraider","owner":"mbrav","description":"Mass git repository search, replace and commit tool written in Rust","archived":false,"fork":false,"pushed_at":"2023-04-23T19:18:46.000Z","size":130,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T06:03:09.525Z","etag":null,"topics":["cli","command-line-tool","commit","git","git2","git2-rs","libgit2","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbrav.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-26T22:31:31.000Z","updated_at":"2024-09-14T15:34:44.000Z","dependencies_parsed_at":"2023-05-14T11:45:23.324Z","dependency_job_id":null,"html_url":"https://github.com/mbrav/gitraider","commit_stats":null,"previous_names":["mbrav/gitraider"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fgitraider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fgitraider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fgitraider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fgitraider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbrav","download_url":"https://codeload.github.com/mbrav/gitraider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253862973,"owners_count":21975588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line-tool","commit","git","git2","git2-rs","libgit2","rust"],"created_at":"2024-11-25T23:16:48.714Z","updated_at":"2025-05-13T02:53:51.269Z","avatar_url":"https://github.com/mbrav.png","language":"Rust","readme":"[![Release](https://github.com/mbrav/gitraider/actions/workflows/release.yml/badge.svg)](https://github.com/mbrav/gitraider/actions/workflows/release.yml)\n[![License](https://img.shields.io/badge/License-BSD_3--Clause-yellow.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![tokei](https://tokei.rs/b1/github/mbrav/gitraider?category=lines)](https://tokei.rs/b1/github/mbrav/gitraider)\n[![Hits-of-Code](https://hitsofcode.com/github/mbrav/gitraider?branch=main)](https://hitsofcode.com/github/mbrav/gitraider/view?branch=main)\n\n# gitraider\n\nMass git repository search, replace and commit tool written in Rust\n\n**⚠️WARNING⚠️** This tool is designed to make changes to hundreds of git repositories, as well as pushing these changes to remote if `--push` flag is used. This project is still WIP so please test on repositories that you have a safe copy.\n\n## Install binary on Linux\n\nTo install the latest version of the binary to `/usr/local/bin/` copy the following into your terminal:\n\n```bash\nlatest_ver=$(curl https://raw.githubusercontent.com/mbrav/gitraider/main/latest)\nfile_name=gitraider_$latest_ver-stable-x86_64-unknown-linux-gnu.tar.gz\ncurl -L -o /tmp/$file_name https://github.com/mbrav/gitraider/releases/download/$latest_ver/$file_name\ntar -xvf /tmp/$file_name -C /tmp/\nsudo cp /tmp/target/release/gitraider /usr/local/bin/\ngitraider -V \n```\n\nIf successful, you will get the following after the end:\n\n```text\ngitraider 0.1.8\n```\n\n## Run from source\n\nTo run, first install Rust's tool chain. Then build:\n\n```bash\ncargo run -- --help\n```\n\nYou will get the following result showing you a help dialogue:\n\n```text\nMass git repository search, replace and commit tool\n\nUsage: gitraider [OPTIONS]\n\nOptions:\n  -p, --path \u003cPATH\u003e      Path to repositories [env: REPO_PATH=] [default: ../repos]\n  -b, --branch \u003cREGEX\u003e   Specify Regex pattern for branches to checkout [env: REPO_BRANCH=] [default: .*]\n  -f, --file \u003cREGEX\u003e     Specify Regex pattern for filename [env: FILE_PATTERN=]\n  -l, --line \u003cREGEX\u003e     Specify Regex pattern for selecting lines [env: LINE_PATTERN=]\n  -s, --select \u003cREGEX\u003e   Specify Regex pattern for selecting parts of a line [env: LINE_SELECT=]\n  -r, --replace \u003cREGEX\u003e  Specify Regex pattern for replacing lines selected by --select [env: LINE_REPLACE=]\n  -c, --commit \u003cTXT\u003e     Specify commit message. No commit if empty [env: COMMIT_MSG=]\n      --push             Specify wether to push commit [env: PUSH_CHANGES=]\n      --dry              Run program in dry mode without altering files and writing to git history [env: DRY_RUN=]\n  -d, --display          Display results at the end of program execution [env: DISPLAY_RES=]\n  -h, --help             Print help\n  -V, --version          Print version\n```\n\n## Example\n\nAs an example, say we have a backend team that is tired of causing outages every other commit because the same Apache Kafka cluster used in production is also used in development (thankfully, this is a made up story). A new Kafka cluster for development was setup and now we need to modify hundreds of repositories in development branches to use a new domain pointing to Kafka's development bootstrap server.\n\nWe need to modify **values.yaml** and **config.env** files in hundreds of git repositories that are cloned to **/home/user/git_repos**. But all these repositories need to be modified under the git branch *development*. Specifically, we need to select lines that contain *\"prod-kafka.backend:9092\"* and replace *\"prod-kafka\"* hostname with *\"dev-kafka\"*.  We can do the following:\n\n```bash\ncargo run -- \\\n  -p \"/home/user/git_repos\" \\\n  -b \"development\\$\" \\\n  -f \"values.yaml|config.env\" \\\n  -l \"prod-kafka.backend:9092\" \\\n  -s \"prod-kafka\" \\\n  -r \"dev-kafka\" \\\n  -c \"Change bootstrap server url from prod-kafka to dev-kafka\" \\\n  --push -d\n```\n\nAfter running the command with the `-d` flag we get the following report:\n\n```text\nRepo mbrav/test-repo\n  Checking out development\n  Success checking out branch 'development' 0290ec568bbd541420454e64b5a7dda6a9642554\n  Staged 'values.yaml'\n  Success commit 'Change bootstrap server url from prod-kafka to dev-kafka' d93cb354791ccb4a540b767c70ea480d4cbd580a\nREPORT                                                                                               \nFn - Matched file with number of matched lines                                                                           \n  Ln - Original line, line number                                                                                     \n  Rn - Replace line (if present), line number \nGIT REPOSITORIES\n\nRepository: mbrav/test-repo\nBranch: development\n  F2: mbrav/test-repo/values.yaml\n    L1:   kafka_bootstrapservers: \"prod-kafka.backend:9092\"\n    R1:   kafka_bootstrapservers: \"test-kafka.backend:9092\"\n    L4:   kafka_url: prod-kafka.backend:9092\n    R4:   kafka_url: test-kafka.backend:9092\nElapsed: 39.170ms\n```\n\n## TODO\n\nFor base functionality to be completed, the following must still be finished:\n\n- [x] ~~Create new commit with specified message~~;\n- [x] ~~Add more elaborate commit changes checks to avoid making duplicate changes and commits~~;\n- [x] ~~Make `dry-run` mode more functional.~~\n- [ ] Push changes to remote after successful commit. Because liggit2, the underlying C library that git2 Rust library offers bindings to, does not support parsing `~/.ssh/` configs, coming up with a workaround is still WIP. Relevant issues:\n  - rust-lang/git2-rs#362\n  - libgit2/libgit2#5640\n  - libgit2/libgit2#4338\n- [ ] Add undo mechanics based on already done changes to avoid deleting and recreating all repositories after each unsuccessful run;\n- [ ] Print current branch name is results assesment as well as commit info, etc\n- [ ] Add optional pull from remote before a commit to branch;\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbrav%2Fgitraider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbrav%2Fgitraider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbrav%2Fgitraider/lists"}