Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Adds base-dir option #74

Merged
merged 1 commit into from Aug 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions scripts/checkout.py
Expand Up @@ -18,13 +18,13 @@


REPOS = ['crane', 'pulp', 'pulp_docker', 'pulp_ostree', 'pulp_puppet', 'pulp_python', 'pulp_rpm']
BASE_DIR_TEMPLATE = '~/devel/%s'


def get_args():
parser = argparse.ArgumentParser(description='Checkout your repos to a version of Pulp')
parser.add_argument('--version', default='master', help='the version of Pulp to check out')
parser.add_argument('--remote', default='pulp', help='the name of the pulp remote to fetch from')
parser.add_argument('--base-dir', default='../', help='the directory that contains your pulp checkouts.')
return parser.parse_args()


Expand All @@ -40,7 +40,7 @@ def get_yaml(args):

def check_checkouts(args):
for repo in REPOS:
checkout_path = os.path.expanduser(BASE_DIR_TEMPLATE % repo)
checkout_path = args.base_dir_template.format(repo)
if os.path.exists(checkout_path):
try:
subprocess.check_call(["git", "diff", "--exit-code"], cwd=checkout_path)
Expand All @@ -51,7 +51,7 @@ def check_checkouts(args):

def fetch_and_checkout(args, yaml):
for repo in REPOS:
checkout_path = os.path.expanduser(BASE_DIR_TEMPLATE % repo)
checkout_path = args.base_dir_template.format(repo)
if os.path.exists(checkout_path):
subprocess.check_call(["git", "fetch", args.remote], cwd=checkout_path)
for entry in yaml['repositories']:
Expand All @@ -60,8 +60,19 @@ def fetch_and_checkout(args, yaml):
subprocess.call(["find", "./", "-name", "*.py[c0]", "-delete"], cwd=checkout_path)


def validate_and_add_path(args):
full_path = os.path.expanduser(args.base_dir)
if not os.path.isdir(full_path):
raise Exception("The directory {0} is not a valid directory".format(full_path))
if os.access(full_path, os.R_OK):
args.base_dir_template = full_path + '{0}'
return args
raise Exception("The directory {0} is not readable")


def main():
args = get_args()
args = validate_and_add_path(args)
check_checkouts(args)
yaml = get_yaml(args)
fetch_and_checkout(args, yaml)
Expand Down