$ rpt -h
Clone or pull multiple GitHub organization repositories.
Usage: rpt [-f|--filter <arg>] [-g|--github-org <arg>] [-h|--help] <workspace>
<workspace>: directory where git repositories are located
-f, --filter: regex filters, space separated list (no default)
-g, --github-org: GitHub Organisation name (no default)
-h, --help: Prints help
This tool is designed to automate the task of pulling multiple git repositories. It will scan your GitHub organization's repos based on a filter and clone or pull them.
This script requires:
- jq
- git
- gnu parallel or xargs
- curl, sed, grep, etc.
Installing is just cloning the repository.
git clone [email protected]:Hallian/repo-pull-tool.git ~/.rpt
You can either just run the script directly with ~/.rpt/repo-pull-tool.sh
or you can make an alias, e.g. rpt
:
echo 'alias rpt="~/.rpt/repo-pull-tool.sh"' >> ~/.bashrc
# OR:
echo 'alias rpt="~/.rpt/repo-pull-tool.sh"' >> ~/.bash_profile
This script needs a GitHub personal access token token to query the GitHub API for your organization's repositories.
You can either supply this each time your run the script or put it in some place convenient, e.g. ~/.bashrc
, ~/.bash_profile
, ...
export GITHUB_TOKEN="github-token-with-repo-access"
The script takes GitHub organization name as the first parameter, a workspace directory i.e. where the repositories are/will be cloned to and finally a list of regex filters.
rpt ~/workspace -g GitHubOrgName -f "^awesome-project- ^boring-project"
The above pull all repositories starting with awesome-project-
and boring-project
into ~/workspace
.
To make things easy and quick, make aliases to your ~/.bashrc
:
alias awesome-pull='rpt GitHubOrgName ~/workspace "^awesome-project-"'
alias boring-pull='rpt GitHubOrgName ~/workspace "^boring-project-"'
To get details on the various parameters you can obtain help with the -h
flag.
rpt -h
This project endevours to provide extensive shellspec tests to ensure functionality of the script on all OSes. The aim of this tool is to be 100% covered with tests and work on all major operating systems.
shellspec
Why write this script? Partly because I got tired of writing the same repo pull script every time I switched consulting gigs to a new client and partly due to a desire to see if one could in fact write maintainable bash scripts that could be expected to run on all operating systems and not break at the drop of a hat. Extensive automated testing seems like the only feasible way to approach the matter.