multi-gitter allows you to make changes in multiple repositories simultaneously. This is archived by running a script or program in the context of all repositories and if any changes are made, a pull request is created that can be merged manually by the set reviewers, or automatically by multi-gitter when CI pipelines has completed successfully.
It currently supports GitHub and GitLab where you can run it on all repositories in an organization, group, user or specify individual repositories. For each repository, the script will run in the context of the root folder, and if any changes is done to the filesystem together with an exit code of 0, the changes will be committed and pushed as a pull/merge request.
$ multi-gitter run ./my-script.sh -o my-org -m "Commit message" -B branch-name
If you are running an interpreted language or similar, it's important to specify the path as an absolute value (since the script will be run in the context of each repository). Using the $PWD
variable helps with this.
$ multi-gitter run "python $PWD/run.py" -o my-org -m "Commit message" -B branch-name
$ multi-gitter run "node $PWD/script.js" -R repo1 -r repo2 -m "Commit message" -B branch-name
$ multi-gitter run "go run $PWD/main.go" -u my-user -m "Commit message" -B branch-name
You might want to test your changes before creating commits. The --dry-run
provides an easy way to test without actually making any modifications. It works well with setting the log level to debug
with --log-level=debug
to also print the changes that would have been made.
$ multi-gitter run ./script.sh --dry-run --log-level=debug -o my-org -m "Commit message" -B branch-name
Find the binary for your operating system from the release page and download it.
To automatically install the latest version
curl -s https://raw.githubusercontent.com/lindell/multi-gitter/master/install.sh | sh
You can also install from source with go get
, this is not recommended for most cases.
go get github.com/lindell/multi-gitter
- run Clones multiple repostories, run a script in that directory, and creates a PR with those changes.
- merge Merge pull requests.
- status Get the status of pull requests.
This command will clone down multiple repositories. For each of those repositories, the script will be run in the context of that repository. If the script finished with a zero exit code, and the script resulted in file changes, a pull request will be created with.
The environment variable REPOSITORY_NAME will be set to the name of the repository currently being executed by the script.
Usage:
multi-gitter run [script path] [flags]
Flags:
--author-email string If set, this fields will be used as the email of the committer
--author-name string If set, this fields will be used as the name of the committer
-B, --branch string The name of the branch where changes are committed. (default "multi-gitter-branch")
-m, --commit-message string The commit message. Will default to title + body if none is set.
-C, --concurrent int The maximum number of concurrent runs (default 1)
-d, --dry-run Run without pushing changes or creating pull requests
-M, --max-reviewers int If this value is set, reviewers will be randomized
-b, --pr-body string The body of the commit message. Will default to everything but the first line of the commit message if none is set.
-t, --pr-title string The title of the PR. Will default to the first line of the commit message if none is set.
-r, --reviewers strings The username of the reviewers to be added on the pull request.
Global Flags:
-g, --gh-base-url string Base URL of the (v3) GitHub API, needs to be changed if GitHub enterprise is used.
-G, --group strings The name of a GitLab organization. All repositories in that group will be used.
-L, --log-level string The level of logging that should be made. Available values: trace, debug, info, error (default "info")
-o, --org strings The name of a GitHub organization. All repositories in that organization will be used.
-P, --platform string The platform that is used. Available values: github, gitlab (default "github")
-p, --project strings The name, including owner of a GitLab project in the format "ownerName/repoName"
-R, --repo strings The name, including owner of a GitHub repository in the format "ownerName/repoName"
-T, --token string The GitHub/GitLab personal access token. Can also be set using the GITHUB_TOKEN/GITLAB_TOKEN environment variable.
-u, --user strings The name of a user. All repositories owned by that user will be used.
Merge pull requests with a specified branch name in an organization and with specified conditions.
Usage:
multi-gitter merge [flags]
Flags:
-B, --branch string The name of the branch where changes are committed. (default "multi-gitter-branch")
Global Flags:
-g, --gh-base-url string Base URL of the (v3) GitHub API, needs to be changed if GitHub enterprise is used.
-G, --group strings The name of a GitLab organization. All repositories in that group will be used.
-L, --log-level string The level of logging that should be made. Available values: trace, debug, info, error (default "info")
-o, --org strings The name of a GitHub organization. All repositories in that organization will be used.
-P, --platform string The platform that is used. Available values: github, gitlab (default "github")
-p, --project strings The name, including owner of a GitLab project in the format "ownerName/repoName"
-R, --repo strings The name, including owner of a GitHub repository in the format "ownerName/repoName"
-T, --token string The GitHub/GitLab personal access token. Can also be set using the GITHUB_TOKEN/GITLAB_TOKEN environment variable.
-u, --user strings The name of a user. All repositories owned by that user will be used.
Get the status of all pull requests with a specified branch name in an organization.
Usage:
multi-gitter status [flags]
Flags:
-B, --branch string The name of the branch where changes are committed. (default "multi-gitter-branch")
Global Flags:
-g, --gh-base-url string Base URL of the (v3) GitHub API, needs to be changed if GitHub enterprise is used.
-G, --group strings The name of a GitLab organization. All repositories in that group will be used.
-L, --log-level string The level of logging that should be made. Available values: trace, debug, info, error (default "info")
-o, --org strings The name of a GitHub organization. All repositories in that organization will be used.
-P, --platform string The platform that is used. Available values: github, gitlab (default "github")
-p, --project strings The name, including owner of a GitLab project in the format "ownerName/repoName"
-R, --repo strings The name, including owner of a GitHub repository in the format "ownerName/repoName"
-T, --token string The GitHub/GitLab personal access token. Can also be set using the GITHUB_TOKEN/GITLAB_TOKEN environment variable.
-u, --user strings The name of a user. All repositories owned by that user will be used.
Replace text in all files
#!/bin/bash
# Assuming you are using gnu sed, if you are running this on a mac, please see https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux
find ./ -type f -exec sed -i -e 's/apple/orange/g' {} \;
Fix linting problems in all your go repositories
#!/bin/bash
golangci-lint run ./... --fix
Updates a go module to a new (patch/minor) version
#!/bin/bash
### Change these values ###
MODULE=github.com/go-git/go-git/v5
VERSION=v5.1.0
# Check if the module already exist, abort if it does not
go list -m $MODULE &> /dev/null
status_code=$?
if [ $status_code -ne 0 ]; then
echo "Module \"$MODULE\" does not exist"
exit 1
fi
go get $MODULE@$VERSION
Updates a npm dependency if it does exist
#!/bin/bash
### Change these values ###
PACKAGE=webpack
VERSION=4.43.0
if [ ! -f "package.json" ]; then
echo "package.json does not exist"
exit 1
fi
# Check if the package already exist (without having to install all packages first), abort if it does not
current_version=`jq ".dependencies[\"$PACKAGE\"]" package.json`
if [ "$current_version" == "null" ];
then
echo "Package \"$PACKAGE\" does not exist"
exit 2
fi
npm install --save $PACKAGE@$VERSION