Giter Club home page Giter Club logo

broeser / bulk-find-and-replace-in-git-repositories Goto Github PK

View Code? Open in Web Editor NEW

This project forked from omerkarabacak/bulk-find-and-replace-in-git-repositories

0.0 0.0 0.0 5 KB

This script is useful when you want to change multiple part of multiple files in multiple git repositories in bulk. Script is creating a new branch from the given base branch and committing changes into it. Maybe push to remote also can be added with small change.

Home Page: https://itnext.io/bulk-find-and-replace-in-multiple-files-in-multiple-git-repositories-487c7c433b75

Python 80.61% Dockerfile 19.39%

bulk-find-and-replace-in-git-repositories's Introduction

Bulk Find and Replace in multiple files in multiple Git Repositories

Area of use for this script

This script is useful when you want to change multiple part of multiple files in multiple git repositories in bulk. Script is creating a new branch from the given base branch and committing changes into it. Maybe push to remote also can be added with small change.

I used this script for changing the auto scaling config inside the Cloudformation templates for multiple micro services in our project.

How to run the script?

First clone repository

git clone https://github.com/omerkarabacak/bulk-find-and-replace-in-git-repositories.git

What to do before run?

In config.json file, change these;

  • Add your new branch names and repositories in repository_list
  • Add texts to find and replace find_and_replace_list
  • Add files to check in file_list
  • Change commit message commit_message
  • Change base branch base_branch
  • Change repository directory if needed repositories_directory
  • Change author name repository_author.name
  • Change author email repository_author.email
  • Change SSH key path if you need something specific ssh_key

You are ready to go!

How to run with Docker?

There are 2 options. You can build your Docker image with Dockerfile or use ready public Docker image from Docker Hub.

Option 1: Build your own Docker image and use it

Build Docker image:

docker build -t bulk-find-and-replace-in-git-repositories:1.0 .

Run with built local Docker image:

docker run --rm -v $(pwd)/config.json:/app/config.json -v $(pwd)/repositories:/app/repositories -v ~/.ssh/id_rsa:/root/.ssh/id_rsa bulk-find-and-replace-in-git-repositories:1.0

Option 2: Use public Docker image hosted on Docker Hub

Run with public Docker image:

docker run --rm -v $(pwd)/config.json:/app/config.json -v $(pwd)/repositories:/app/repositories -v ~/.ssh/id_rsa:/root/.ssh/id_rsa omerkarabacak/bulk-find-and-replace-in-git-repositories:1.0

How to run with Python virtual environment?

First create virtual environment

python3 -m venv env

Enter virtual environment

source env/bin/activate

Install dependencies

pip install -r requirements.txt

Run script

python findandreplace.py

Which Python version?

Tested with 3.6.8

bulk-find-and-replace-in-git-repositories's People

Contributors

omerkarabacak avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.