forked from cerc-io/stack-orchestrator
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
938f51ef8c | ||
|
|
6d620ba9c2 | ||
|
|
0c4c128465 | ||
|
|
97c1ae1c43 | ||
|
|
ec6b5439f4 |
@@ -1,35 +1,36 @@
|
||||
cerc-io/ipld-eth-db
|
||||
cerc-io/go-ethereum
|
||||
cerc-io/ipld-eth-server
|
||||
cerc-io/eth-statediff-service
|
||||
cerc-io/eth-statediff-fill-service
|
||||
cerc-io/ipld-eth-db-validator
|
||||
cerc-io/ipld-eth-beacon-indexer
|
||||
cerc-io/ipld-eth-beacon-db
|
||||
cerc-io/laconicd
|
||||
cerc-io/laconic-sdk
|
||||
cerc-io/laconic-registry-cli
|
||||
cerc-io/laconic-console
|
||||
cerc-io/mobymask-watcher
|
||||
cerc-io/watcher-ts
|
||||
cerc-io/mobymask-v2-watcher-ts
|
||||
cerc-io/MobyMask
|
||||
vulcanize/uniswap-watcher-ts
|
||||
vulcanize/uniswap-v3-info
|
||||
vulcanize/assemblyscript
|
||||
cerc-io/eth-probe
|
||||
cerc-io/tx-spammer
|
||||
dboreham/foundry
|
||||
lirewine/gem
|
||||
lirewine/debug
|
||||
lirewine/crypto
|
||||
lirewine/sdk
|
||||
telackey/act_runner
|
||||
ethereum-optimism/op-geth
|
||||
ethereum-optimism/optimism
|
||||
pokt-network/pocket-core
|
||||
pokt-network/pocket-core-deployments
|
||||
cerc-io/azimuth-watcher-ts
|
||||
cerc-io/ipld-eth-state-snapshot
|
||||
cerc-io/gelato-watcher-ts
|
||||
filecoin-project/lotus
|
||||
github.com/cerc-io/ipld-eth-db
|
||||
github.com/cerc-io/go-ethereum
|
||||
github.com/cerc-io/ipld-eth-server
|
||||
github.com/cerc-io/eth-statediff-service
|
||||
github.com/cerc-io/eth-statediff-fill-service
|
||||
github.com/cerc-io/ipld-eth-db-validator
|
||||
github.com/cerc-io/ipld-eth-beacon-indexer
|
||||
github.com/cerc-io/ipld-eth-beacon-db
|
||||
github.com/cerc-io/laconicd
|
||||
github.com/cerc-io/laconic-sdk
|
||||
github.com/cerc-io/laconic-registry-cli
|
||||
github.com/cerc-io/laconic-console
|
||||
github.com/cerc-io/mobymask-watcher
|
||||
github.com/cerc-io/watcher-ts
|
||||
github.com/cerc-io/mobymask-v2-watcher-ts
|
||||
github.com/cerc-io/MobyMask
|
||||
github.com/vulcanize/uniswap-watcher-ts
|
||||
github.com/vulcanize/uniswap-v3-info
|
||||
github.com/vulcanize/assemblyscript
|
||||
github.com/cerc-io/eth-probe
|
||||
github.com/cerc-io/tx-spammer
|
||||
github.com/dboreham/foundry
|
||||
github.com/lirewine/gem
|
||||
github.com/lirewine/debug
|
||||
github.com/lirewine/crypto
|
||||
github.com/lirewine/sdk
|
||||
github.com/telackey/act_runner
|
||||
github.com/ethereum-optimism/op-geth
|
||||
github.com/ethereum-optimism/optimism
|
||||
github.com/pokt-network/pocket-core
|
||||
github.com/pokt-network/pocket-core-deployments
|
||||
github.com/cerc-io/azimuth-watcher-ts
|
||||
github.com/cerc-io/ipld-eth-state-snapshot
|
||||
github.com/cerc-io/gelato-watcher-ts
|
||||
github.com/filecoin-project/lotus
|
||||
git.vdb.to/cerc-io/test-project
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version: "1.0"
|
||||
name: azimuth
|
||||
repos:
|
||||
- cerc-io/azimuth-watcher-ts
|
||||
- github.com/cerc-io/azimuth-watcher-ts
|
||||
containers:
|
||||
- cerc/watcher-azimuth
|
||||
pods:
|
||||
|
||||
@@ -2,10 +2,10 @@ version: "1.0"
|
||||
name: chain-chunker
|
||||
decription: "Stack to build containers for chain-chunker"
|
||||
repos:
|
||||
- cerc-io/ipld-eth-state-snapshot
|
||||
- cerc-io/eth-statediff-service
|
||||
- cerc-io/ipld-eth-db
|
||||
- cerc-io/ipld-eth-server
|
||||
- github.com/cerc-io/ipld-eth-state-snapshot@v5
|
||||
- github.com/cerc-io/eth-statediff-service@v5
|
||||
- github.com/cerc-io/ipld-eth-db@v5
|
||||
- github.com/cerc-io/ipld-eth-server@v5
|
||||
containers:
|
||||
- cerc/ipld-eth-state-snapshot
|
||||
- cerc/eth-statediff-service
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
version: "1.0"
|
||||
name: erc20-watcher
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- cerc-io/ipld-eth-db
|
||||
- cerc-io/ipld-eth-server
|
||||
- cerc-io/watcher-ts
|
||||
- dboreham/foundry
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/cerc-io/ipld-eth-db
|
||||
- github.com/cerc-io/ipld-eth-server
|
||||
- github.com/cerc-io/watcher-ts
|
||||
- github.com/dboreham/foundry
|
||||
containers:
|
||||
- cerc/foundry
|
||||
- cerc/go-ethereum
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
version: "1.0"
|
||||
name: erc721-watcher
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- cerc-io/ipld-eth-db
|
||||
- cerc-io/ipld-eth-server
|
||||
- cerc-io/watcher-ts
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/cerc-io/ipld-eth-db
|
||||
- github.com/cerc-io/ipld-eth-server
|
||||
- github.com/cerc-io/watcher-ts
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/go-ethereum-foundry
|
||||
|
||||
@@ -2,11 +2,11 @@ version: "1.0"
|
||||
name: fixturenet-eth-loaded
|
||||
decription: "Loaded Ethereum Fixturenet"
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- cerc-io/tx-spammer
|
||||
- cerc-io/ipld-eth-server
|
||||
- cerc-io/ipld-eth-db
|
||||
- cerc/go-ethereum
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/cerc-io/tx-spammer
|
||||
- github.com/cerc-io/ipld-eth-server
|
||||
- github.com/cerc-io/ipld-eth-db
|
||||
- github.com/cerc-io/go-ethereum
|
||||
containers:
|
||||
- cerc/lighthouse
|
||||
- cerc/fixturenet-eth-geth
|
||||
|
||||
@@ -2,8 +2,8 @@ version: "1.2"
|
||||
name: fixturenet-eth-tx
|
||||
decription: "Ethereum Fixturenet w/ tx-spammer"
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- cerc-io/tx-spammer
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/cerc-io/tx-spammer
|
||||
- dboreham/foundry
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
|
||||
@@ -66,7 +66,7 @@ It is not necessary to use them all at once, but a complete example follows:
|
||||
|
||||
```
|
||||
# Setup
|
||||
$ laconic-so setup-repositories --include cerc-io/go-ethereum,cerc-io/ipld-eth-db,cerc-io/ipld-eth-server,cerc-io/ipld-eth-beacon-db,cerc-io/ipld-eth-beacon-indexer,cerc-io/eth-probe,cerc-io/tx-spammer
|
||||
$ laconic-so setup-repositories --include github.com/cerc-io/go-ethereum,github.com/cerc-io/ipld-eth-db,github.com/cerc-io/ipld-eth-server,github.com/cerc-io/ipld-eth-beacon-db,github.com/cerc-io/ipld-eth-beacon-indexer,github.com/cerc-io/eth-probe,github.com/cerc-io/tx-spammer
|
||||
|
||||
# Build
|
||||
$ laconic-so build-containers --include cerc/go-ethereum,cerc/lighthouse,cerc/fixturenet-eth-geth,cerc/fixturenet-eth-lighthouse,cerc/ipld-eth-db,cerc/ipld-eth-server,cerc/ipld-eth-beacon-db,cerc/ipld-eth-beacon-indexer,cerc/eth-probe,cerc/keycloak,cerc/tx-spammer
|
||||
|
||||
@@ -2,8 +2,8 @@ version: "1.1"
|
||||
name: fixturenet-eth
|
||||
decription: "Ethereum Fixturenet"
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- dboreham/foundry
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/dboreham/foundry
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
|
||||
@@ -2,14 +2,14 @@ version: "1.1"
|
||||
name: fixturenet-laconic-loaded
|
||||
description: "A full featured laconic fixturenet"
|
||||
repos:
|
||||
- cerc-io/laconicd
|
||||
- lirewine/debug
|
||||
- lirewine/crypto
|
||||
- lirewine/gem
|
||||
- lirewine/sdk
|
||||
- cerc-io/laconic-sdk
|
||||
- cerc-io/laconic-registry-cli
|
||||
- cerc-io/laconic-console
|
||||
- github.com/cerc-io/laconicd
|
||||
- github.com/lirewine/debug
|
||||
- github.com/lirewine/crypto
|
||||
- github.com/lirewine/gem
|
||||
- github.com/lirewine/sdk
|
||||
- github.com/cerc-io/laconic-sdk
|
||||
- github.com/cerc-io/laconic-registry-cli
|
||||
- github.com/cerc-io/laconic-console
|
||||
npms:
|
||||
- laconic-sdk
|
||||
- laconic-registry-cli
|
||||
|
||||
@@ -2,9 +2,9 @@ version: "1.0"
|
||||
name: fixturenet-laconicd
|
||||
description: "A laconicd fixturenet"
|
||||
repos:
|
||||
- cerc-io/laconicd
|
||||
- cerc-io/laconic-sdk
|
||||
- cerc-io/laconic-registry-cli
|
||||
- github.com/cerc-io/laconicd
|
||||
- github.com/cerc-io/laconic-sdk
|
||||
- github.com/cerc-io/laconic-registry-cli
|
||||
npms:
|
||||
- laconic-sdk
|
||||
- laconic-registry-cli
|
||||
|
||||
@@ -2,7 +2,7 @@ version: "1.0"
|
||||
name: fixturenet-lotus
|
||||
description: "A lotus fixturenet"
|
||||
repos:
|
||||
- filecoin-project/lotus
|
||||
- github.com/filecoin-project/lotus
|
||||
containers:
|
||||
- cerc/lotus
|
||||
pods:
|
||||
|
||||
@@ -9,7 +9,7 @@ Prerequisite: An L1 Ethereum RPC endpoint
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack fixturenet-optimism setup-repositories --exclude cerc-io/go-ethereum
|
||||
laconic-so --stack fixturenet-optimism setup-repositories --exclude github.com/cerc-io/go-ethereum
|
||||
|
||||
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
|
||||
```
|
||||
|
||||
@@ -2,10 +2,10 @@ version: "1.0"
|
||||
name: fixturenet-optimism
|
||||
decription: "Optimism Fixturenet"
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- dboreham/foundry
|
||||
- ethereum-optimism/optimism
|
||||
- ethereum-optimism/op-geth
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/dboreham/foundry
|
||||
- github.com/ethereum-optimism/optimism
|
||||
- github.com/ethereum-optimism/op-geth
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
|
||||
@@ -2,9 +2,9 @@ version: "1.0"
|
||||
name: fixturenet-pocket
|
||||
description: "A single node pocket chain that can serve relays from the geth-1 node in eth-fixturenet"
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- pokt-network/pocket-core
|
||||
- pokt-network/pocket-core-deployments # contains the dockerfile
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/pokt-network/pocket-core
|
||||
- github.com/pokt-network/pocket-core-deployments # contains the dockerfile
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version: "1.0"
|
||||
name: gelato
|
||||
repos:
|
||||
- cerc-io/gelato-watcher-ts
|
||||
- github.com/cerc-io/gelato-watcher-ts
|
||||
containers:
|
||||
- cerc/watcher-gelato
|
||||
pods:
|
||||
|
||||
@@ -9,7 +9,7 @@ Prerequisite: L2 Optimism Geth and Node RPC endpoints
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts,cerc-io/mobymask-v2-watcher-ts
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include github.com/cerc-io/MobyMask,github.com/cerc-io/watcher-ts,github.com/cerc-io/mobymask-v2-watcher-ts
|
||||
|
||||
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned below and re-run the command
|
||||
```
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
version: "1.0"
|
||||
name: mobymask-v2
|
||||
repos:
|
||||
- cerc-io/go-ethereum
|
||||
- dboreham/foundry
|
||||
- ethereum-optimism/optimism
|
||||
- ethereum-optimism/op-geth
|
||||
- cerc-io/watcher-ts
|
||||
- cerc-io/mobymask-v2-watcher-ts
|
||||
- cerc-io/MobyMask
|
||||
- github.com/cerc-io/go-ethereum
|
||||
- github.com/dboreham/foundry
|
||||
- github.com/ethereum-optimism/optimism
|
||||
- github.com/ethereum-optimism/op-geth
|
||||
- github.com/cerc-io/watcher-ts
|
||||
- github.com/cerc-io/mobymask-v2-watcher-ts
|
||||
- github.com/cerc-io/MobyMask
|
||||
containers:
|
||||
- cerc/go-ethereum
|
||||
- cerc/lighthouse
|
||||
|
||||
@@ -14,7 +14,7 @@ This demo has been tested on a `Ubuntu 22.04 LTS` machine with `8GB` of RAM
|
||||
Clone required repositories:
|
||||
|
||||
```bash
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include cerc-io/MobyMask,cerc-io/watcher-ts,cerc-io/mobymask-v2-watcher-ts
|
||||
laconic-so --stack mobymask-v2 setup-repositories --include github.com/cerc-io/MobyMask,github.com/cerc-io/watcher-ts,github.com/cerc-io/mobymask-v2-watcher-ts
|
||||
|
||||
# This will clone the required repositories at ~/cerc
|
||||
# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories mentioned in the next step and re-run the command
|
||||
|
||||
@@ -11,7 +11,7 @@ This deployment expects that ipld-eth-server's endpoints are available on the lo
|
||||
## Clone required repositories
|
||||
|
||||
```
|
||||
$ laconic-so setup-repositories --include cerc-io/watcher-ts
|
||||
$ laconic-so setup-repositories --include github.com/cerc-io/watcher-ts
|
||||
```
|
||||
|
||||
## Build the watcher container
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
version: "1.0"
|
||||
name: mobymask-watcher
|
||||
repos:
|
||||
- cerc-io/watcher-ts/v0.2.19
|
||||
- github.com/cerc-io/watcher-ts/v0.2.19
|
||||
containers:
|
||||
- cerc/watcher-mobymask
|
||||
pods:
|
||||
|
||||
@@ -2,8 +2,8 @@ version: "1.1"
|
||||
name: package-registry
|
||||
decription: "Local Package Registry"
|
||||
repos:
|
||||
- cerc-io/hosting
|
||||
- telackey/act_runner
|
||||
- github.com/cerc-io/hosting
|
||||
- gitea.com/gitea/act_runner
|
||||
containers:
|
||||
- cerc/act-runner
|
||||
- cerc/act-runner-task-executor
|
||||
|
||||
@@ -2,7 +2,8 @@ version: "1.0"
|
||||
name: test
|
||||
description: "A test stack"
|
||||
repos:
|
||||
- cerc-io/laconicd
|
||||
- github.com/cerc-io/laconicd
|
||||
- git.vdb.to/cerc-io/test-project@test-branch
|
||||
containers:
|
||||
- cerc/test-container
|
||||
pods:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
version: "1.0"
|
||||
name: uniswap-v3
|
||||
repos:
|
||||
- vulcanize/uniswap-watcher-ts
|
||||
- vulcanize/uniswap-v3-info
|
||||
- github.com/vulcanize/uniswap-watcher-ts
|
||||
- github.com/vulcanize/uniswap-v3-info
|
||||
containers:
|
||||
- cerc/watcher-uniswap-v3
|
||||
- cerc/uniswap-v3-info
|
||||
|
||||
+119
-59
@@ -52,15 +52,111 @@ def is_git_repo(path):
|
||||
# )
|
||||
|
||||
|
||||
def branch_strip(s):
|
||||
return s.split('@')[0]
|
||||
|
||||
|
||||
def host_and_path_for_repo(fully_qualified_repo):
|
||||
repo_branch_split = fully_qualified_repo.split("@")
|
||||
repo_branch = repo_branch_split[-1] if len(repo_branch_split) > 1 else None
|
||||
repo_host_split = repo_branch_split[0].split("/")
|
||||
# Legacy unqualified repo means github
|
||||
if len(repo_host_split) == 2:
|
||||
return "github.com", "/".join(repo_host_split), repo_branch
|
||||
else:
|
||||
if len(repo_host_split) == 3:
|
||||
# First part is the host
|
||||
return repo_host_split[0], "/".join(repo_host_split[1:]), repo_branch
|
||||
|
||||
|
||||
# TODO: fix the messy arg list here
|
||||
def process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_path, branches_array, fully_qualified_repo):
|
||||
repo_host, repo_path, repo_branch = host_and_path_for_repo(fully_qualified_repo)
|
||||
git_ssh_prefix = f"git@{repo_host}:"
|
||||
git_http_prefix = f"https://{repo_host}/"
|
||||
full_github_repo_path = f"{git_ssh_prefix if git_ssh else git_http_prefix}{repo_path}"
|
||||
repoName = repo_path.split("/")[-1]
|
||||
full_filesystem_repo_path = os.path.join(dev_root_path, repoName)
|
||||
is_present = os.path.isdir(full_filesystem_repo_path)
|
||||
current_repo_branch = git.Repo(full_filesystem_repo_path).active_branch.name if is_present else None
|
||||
if not quiet:
|
||||
present_text = f"already exists active branch: {current_repo_branch}" if is_present \
|
||||
else 'Needs to be fetched'
|
||||
print(f"Checking: {full_filesystem_repo_path}: {present_text}")
|
||||
# Quick check that it's actually a repo
|
||||
if is_present:
|
||||
if not is_git_repo(full_filesystem_repo_path):
|
||||
print(f"Error: {full_filesystem_repo_path} does not contain a valid git repository")
|
||||
sys.exit(1)
|
||||
else:
|
||||
if pull:
|
||||
if verbose:
|
||||
print(f"Running git pull for {full_filesystem_repo_path}")
|
||||
if not check_only:
|
||||
git_repo = git.Repo(full_filesystem_repo_path)
|
||||
origin = git_repo.remotes.origin
|
||||
origin.pull(progress=None if quiet else GitProgress())
|
||||
else:
|
||||
print("(git pull skipped)")
|
||||
if not is_present:
|
||||
# Clone
|
||||
if verbose:
|
||||
print(f'Running git clone for {full_github_repo_path} into {full_filesystem_repo_path}')
|
||||
if not dry_run:
|
||||
git.Repo.clone_from(full_github_repo_path,
|
||||
full_filesystem_repo_path,
|
||||
progress=None if quiet else GitProgress())
|
||||
else:
|
||||
print("(git clone skipped)")
|
||||
# Checkout the requested branch, if one was specified
|
||||
branch_to_checkout = None
|
||||
if branches_array:
|
||||
# Find the current repo in the branches list
|
||||
print("Checking")
|
||||
for repo_branch in branches_array:
|
||||
repo_branch_tuple = repo_branch.split(" ")
|
||||
if repo_branch_tuple[0] == branch_strip(fully_qualified_repo):
|
||||
# checkout specified branch
|
||||
branch_to_checkout = repo_branch_tuple[1]
|
||||
else:
|
||||
branch_to_checkout = repo_branch
|
||||
|
||||
if branch_to_checkout:
|
||||
if current_repo_branch is None or (current_repo_branch and (current_repo_branch != branch_to_checkout)):
|
||||
if not quiet:
|
||||
print(f"switching to branch {branch_to_checkout} in repo {repo_path}")
|
||||
git_repo = git.Repo(full_filesystem_repo_path)
|
||||
git_repo.git.checkout(branch_to_checkout)
|
||||
else:
|
||||
if verbose:
|
||||
print(f"repo {repo_path} is already switched to branch {branch_to_checkout}")
|
||||
|
||||
|
||||
def parse_branches(branches_string):
|
||||
if branches_string:
|
||||
result_array = []
|
||||
branches_directives = branches_string.split(",")
|
||||
for branch_directive in branches_directives:
|
||||
split_directive = branch_directive.split("@")
|
||||
if len(split_directive) != 2:
|
||||
print(f"Error: branch specified is not valid: {branch_directive}")
|
||||
sys.exit(1)
|
||||
result_array.append(f"{split_directive[0]} {split_directive[1]}")
|
||||
return result_array
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option("--include", help="only clone these repositories")
|
||||
@click.option("--exclude", help="don\'t clone these repositories")
|
||||
@click.option('--git-ssh', is_flag=True, default=False)
|
||||
@click.option('--check-only', is_flag=True, default=False)
|
||||
@click.option('--pull', is_flag=True, default=False)
|
||||
@click.option("--branches", help="override branches for repositories")
|
||||
@click.option('--branches-file', help="checkout branches specified in this file")
|
||||
@click.pass_context
|
||||
def command(ctx, include, exclude, git_ssh, check_only, pull, branches_file):
|
||||
def command(ctx, include, exclude, git_ssh, check_only, pull, branches, branches_file):
|
||||
'''git clone the set of repositories required to build the complete system from source'''
|
||||
|
||||
quiet = ctx.obj.quiet
|
||||
@@ -68,16 +164,29 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches_file):
|
||||
dry_run = ctx.obj.dry_run
|
||||
stack = ctx.obj.stack
|
||||
|
||||
branches = []
|
||||
branches_array = []
|
||||
|
||||
# TODO: branches file needs to be re-worked in the context of stacks
|
||||
if branches_file:
|
||||
if verbose:
|
||||
print(f"loading branches from: {branches_file}")
|
||||
with open(branches_file) as branches_file_open:
|
||||
branches = branches_file_open.read().splitlines()
|
||||
if verbose:
|
||||
print(f"Branches are: {branches}")
|
||||
if branches:
|
||||
print("Error: can't specify both --branches and --branches-file")
|
||||
sys.exit(1)
|
||||
else:
|
||||
if verbose:
|
||||
print(f"loading branches from: {branches_file}")
|
||||
with open(branches_file) as branches_file_open:
|
||||
branches_array = branches_file_open.read().splitlines()
|
||||
|
||||
print(f"branches: {branches}")
|
||||
if branches:
|
||||
if branches_file:
|
||||
print("Error: can't specify both --branches and --branches-file")
|
||||
sys.exit(1)
|
||||
else:
|
||||
branches_array = parse_branches(branches)
|
||||
|
||||
if branches_array and verbose:
|
||||
print(f"Branches are: {branches_array}")
|
||||
|
||||
local_stack = ctx.obj.local_stack
|
||||
|
||||
@@ -119,64 +228,15 @@ def command(ctx, include, exclude, git_ssh, check_only, pull, branches_file):
|
||||
|
||||
repos = []
|
||||
for repo in repos_in_scope:
|
||||
if include_exclude_check(repo, include, exclude):
|
||||
if include_exclude_check(branch_strip(repo), include, exclude):
|
||||
repos.append(repo)
|
||||
else:
|
||||
if verbose:
|
||||
print(f"Excluding: {repo}")
|
||||
|
||||
def process_repo(repo):
|
||||
git_ssh_prefix = "git@github.com:"
|
||||
git_http_prefix = "https://github.com/"
|
||||
full_github_repo_path = f"{git_ssh_prefix if git_ssh else git_http_prefix}{repo}"
|
||||
repoName = repo.split("/")[-1]
|
||||
full_filesystem_repo_path = os.path.join(dev_root_path, repoName)
|
||||
is_present = os.path.isdir(full_filesystem_repo_path)
|
||||
if not quiet:
|
||||
present_text = f"already exists active branch: {git.Repo(full_filesystem_repo_path).active_branch}" if is_present \
|
||||
else 'Needs to be fetched'
|
||||
print(f"Checking: {full_filesystem_repo_path}: {present_text}")
|
||||
# Quick check that it's actually a repo
|
||||
if is_present:
|
||||
if not is_git_repo(full_filesystem_repo_path):
|
||||
print(f"Error: {full_filesystem_repo_path} does not contain a valid git repository")
|
||||
sys.exit(1)
|
||||
else:
|
||||
if pull:
|
||||
if verbose:
|
||||
print(f"Running git pull for {full_filesystem_repo_path}")
|
||||
if not check_only:
|
||||
git_repo = git.Repo(full_filesystem_repo_path)
|
||||
origin = git_repo.remotes.origin
|
||||
origin.pull(progress=None if quiet else GitProgress())
|
||||
else:
|
||||
print("(git pull skipped)")
|
||||
if not is_present:
|
||||
# Clone
|
||||
if verbose:
|
||||
print(f'Running git clone for {full_github_repo_path} into {full_filesystem_repo_path}')
|
||||
if not dry_run:
|
||||
git.Repo.clone_from(full_github_repo_path,
|
||||
full_filesystem_repo_path,
|
||||
progress=None if quiet else GitProgress())
|
||||
else:
|
||||
print("(git clone skipped)")
|
||||
# Checkout the requested branch, if one was specified
|
||||
if branches:
|
||||
# Find the current repo in the branches list
|
||||
for repo_branch in branches:
|
||||
repo_branch_tuple = repo_branch.split(" ")
|
||||
if repo_branch_tuple[0] == repo:
|
||||
# checkout specified branch
|
||||
branch_to_checkout = repo_branch_tuple[1]
|
||||
if verbose:
|
||||
print(f"checking out branch {branch_to_checkout} in repo {repo}")
|
||||
git_repo = git.Repo(full_filesystem_repo_path)
|
||||
git_repo.git.checkout(branch_to_checkout)
|
||||
|
||||
for repo in repos:
|
||||
try:
|
||||
process_repo(repo)
|
||||
process_repo(verbose, quiet, dry_run, pull, check_only, git_ssh, dev_root_path, branches_array, repo)
|
||||
except git.exc.GitCommandError as error:
|
||||
print(f"\n******* git command returned error exit status:\n{error}")
|
||||
sys.exit(1)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||
|
||||
import click
|
||||
from dataclasses import dataclass
|
||||
|
||||
from app import setup_repositories
|
||||
from app import build_containers
|
||||
@@ -24,17 +25,15 @@ from app import version
|
||||
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
|
||||
|
||||
|
||||
# TODO: this seems kind of weird and heavy on boilerplate -- check it is
|
||||
# the best Python can do for us.
|
||||
class Options(object):
|
||||
def __init__(self, stack, quiet, verbose, dry_run, local_stack, debug, continue_on_error):
|
||||
self.stack = stack
|
||||
self.quiet = quiet
|
||||
self.verbose = verbose
|
||||
self.dry_run = dry_run
|
||||
self.local_stack = local_stack
|
||||
self.debug = debug
|
||||
self.continue_on_error = continue_on_error
|
||||
@dataclass
|
||||
class Options:
|
||||
stack: str
|
||||
quiet: bool = False
|
||||
verbose: bool = False
|
||||
dry_run: bool = False
|
||||
local_stack: bool = False
|
||||
debug: bool = False
|
||||
continue_on_error: bool = False
|
||||
|
||||
|
||||
@click.group(context_settings=CONTEXT_SETTINGS)
|
||||
|
||||
Reference in New Issue
Block a user