|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +#------------------------------------------------------------------------------ |
| 4 | +# Clones external test repositories from solidity-external-tests organization |
| 5 | +# and for each of them pulls latest upstream changes from the main branch and |
| 6 | +# pushes them to our fork. |
| 7 | +# |
| 8 | +# The script assumes that the current user has write access to |
| 9 | +# solidity-external-tests and that git is configured to be able to push there |
| 10 | +# without specifying the password (e.g. with the key already unlocked and loaded |
| 11 | +# into ssh-agent). Otherwise git will keep asking for password for each repository. |
| 12 | +# |
| 13 | +# Usage: |
| 14 | +# |
| 15 | +# ./update_external_repos.sh [<target_dir>] |
| 16 | +# |
| 17 | +# <target_dir>: directory where the clones of the repositories are stored. |
| 18 | +# If omitted, a temporary directory will be created. |
| 19 | +# |
| 20 | +# ------------------------------------------------------------------------------ |
| 21 | +# This file is part of solidity. |
| 22 | +# |
| 23 | +# solidity is free software: you can redistribute it and/or modify |
| 24 | +# it under the terms of the GNU General Public License as published by |
| 25 | +# the Free Software Foundation, either version 3 of the License, or |
| 26 | +# (at your option) any later version. |
| 27 | +# |
| 28 | +# solidity is distributed in the hope that it will be useful, |
| 29 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 30 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 31 | +# GNU General Public License for more details. |
| 32 | +# |
| 33 | +# You should have received a copy of the GNU General Public License |
| 34 | +# along with solidity. If not, see <http://www.gnu.org/licenses/> |
| 35 | +# |
| 36 | +# (c) 2022 solidity contributors. |
| 37 | +#------------------------------------------------------------------------------ |
| 38 | + |
| 39 | +set -euo pipefail |
| 40 | + |
| 41 | +target_dir="${1:-$(mktemp -d -t update_external_repos_XXXXXX)}" |
| 42 | + |
| 43 | +function clone_repo |
| 44 | +{ |
| 45 | + local upstream_user="$1" |
| 46 | + local upstream_repo="$2" |
| 47 | + local fork_name="${3:-$upstream_repo}" |
| 48 | + |
| 49 | + if [[ ! -d $fork_name ]]; then |
| 50 | + git clone "[email protected]:solidity-external-tests/${fork_name}.git" --no-checkout |
| 51 | + else |
| 52 | + echo "Reusing existing repo: ${fork_name}." |
| 53 | + fi |
| 54 | + |
| 55 | + pushd "$fork_name" > /dev/null |
| 56 | + git remote rm upstream 2> /dev/null || true |
| 57 | + git remote add upstream "https://github.com/${upstream_user}/${upstream_repo}" |
| 58 | + popd > /dev/null |
| 59 | +} |
| 60 | + |
| 61 | +function sync_branch |
| 62 | +{ |
| 63 | + local fork_name="$1" |
| 64 | + local branch="$2" |
| 65 | + |
| 66 | + echo "${fork_name}: syncing branch ${branch}..." |
| 67 | + pushd "$fork_name" > /dev/null |
| 68 | + git fetch upstream "$branch" --quiet |
| 69 | + git checkout -B "$branch" --track "upstream/$branch" --quiet |
| 70 | + git merge "upstream/${branch}" --ff-only --quiet |
| 71 | + git push origin "$branch" |
| 72 | + popd > /dev/null |
| 73 | +} |
| 74 | + |
| 75 | +mkdir -p "$target_dir" |
| 76 | + |
| 77 | +echo "Entering ${target_dir}" |
| 78 | +cd "$target_dir" |
| 79 | + |
| 80 | +clone_repo brinktrade brink-core |
| 81 | +clone_repo dapphub dappsys-monolithic |
| 82 | +clone_repo element-fi elf-contracts |
| 83 | +clone_repo ensdomains ens |
| 84 | +clone_repo ensdomains ens-contracts |
| 85 | +clone_repo euler-xyz euler-contracts |
| 86 | +clone_repo gnosis gp-v2-contracts |
| 87 | +clone_repo gnosis mock-contract |
| 88 | +clone_repo gnosis util-contracts |
| 89 | +clone_repo JoinColony colonyNetwork |
| 90 | +clone_repo mycelium-ethereum perpetual-pools-contracts |
| 91 | +clone_repo OpenZeppelin openzeppelin-contracts |
| 92 | +clone_repo paulrberg prb-math |
| 93 | +clone_repo pooltogether v4-core pooltogether-v4-core |
| 94 | +clone_repo safe-global safe-contracts |
| 95 | +clone_repo smartcontractkit chainlink |
| 96 | +clone_repo sushiswap trident |
| 97 | +clone_repo Uniswap v2-core uniswap-v2-core |
| 98 | +clone_repo Uniswap v3-core uniswap-v3-core |
| 99 | +clone_repo wighawag bleeps |
| 100 | +clone_repo yieldprotocol yield-liquidator-v2 |
| 101 | + |
| 102 | +sync_branch brink-core master |
| 103 | +sync_branch dappsys-monolithic master |
| 104 | +sync_branch elf-contracts main |
| 105 | +sync_branch ens master |
| 106 | +sync_branch ens-contracts master |
| 107 | +sync_branch euler-contracts master |
| 108 | +sync_branch gp-v2-contracts main |
| 109 | +sync_branch mock-contract master |
| 110 | +sync_branch util-contracts main |
| 111 | +sync_branch colonyNetwork develop |
| 112 | +sync_branch perpetual-pools-contracts develop |
| 113 | +sync_branch openzeppelin-contracts master |
| 114 | +sync_branch prb-math main |
| 115 | +sync_branch pooltogether-v4-core master |
| 116 | +sync_branch safe-contracts main |
| 117 | +sync_branch chainlink develop |
| 118 | +sync_branch trident master |
| 119 | +sync_branch uniswap-v2-core master |
| 120 | +sync_branch uniswap-v3-core main |
| 121 | +sync_branch bleeps main |
| 122 | +sync_branch yield-liquidator-v2 master |
0 commit comments