Giter VIP home page Giter VIP logo

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

View Code? Open in Web Editor NEW
33.0 2.0 12.0 23 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

License: GNU General Public License v3.0

Python 83.72% Dockerfile 16.28%
python bulk-operation git find-and-replace bulk

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.1 .

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.1

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 ghcr.io/omerkarabacak/bulk-find-and-replace-in-git-repositories:1.1

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

broeser avatar jamesgeddes avatar omerkarabacak avatar sivasareddu avatar ssaredd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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

License

Hi there,

May I request a license on this please?

Thanks!

Building image failure due to ERROR: Location-changing options found in --install-option: ['--prefix']

It seems that the image build is not working due to this pypa/pip#9435.

This is the error:

/usr/local/lib/python3.6/site-packages/pip/_internal/commands/install.py:232: UserWarning: Disabling all use of wheels due to the use of --build-option / --global-option / --install-option. cmdoptions.check_install_build_global(options) ERROR: Location-changing options found in --install-option: ['--prefix'] from command line. This is unsupported, use pip-level options like --user, --prefix, --root, and --target instead.

Automatic pull request and assignees | improvement

Hi, I would like to know if it is possible to implement automatic pull request to code and assigned to another git user. For example, I would like to merge the new branch into the develop branch without having to do this manually. I looked in the GitPython documentation but I didn't find something that helps me. Thanks for your attention, and great code!!

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.