示例#1
0
def migrate_project(args):
    """
    Migrate a Github project from one Github instance to another.

    Migration includes:
        - Project metadata
        - Git repository
        - Issues & pull requests
        - Comments
        - Hooks

    WARNING: This will copy the git repository verbatim. Any commits on the
    target repository that are not also on the source will be lost.

    Note: All issues and comments will be migrated as the target user with
    links back to the source Github instance.
    """
    with cli.catch_api_errors():
        src_org = Organisation(args.src)
        dst_org = Organisation(args.dst)
        src = Repo(args.src)
        dst = Repo(args.dst)

        # Create the repo object
        log.info("Migrating %s to %s -> creating repo", src, dst)
        project = src_org.get_repo(src.repo)
        project['name'] = dst.repo
        dst_org.create_repo(project)

        # Migrate repo data
        migrators.repo.migrate(src, dst)
        migrators.issues.migrate(src, dst)
        migrators.comments.migrate(src, dst)
        migrators.hooks.migrate(src, dst)
示例#2
0
文件: repo.py 项目: alphagov/ghtools
def create(args):
    """
    Create a repo with specified name
    """
    repo = Repo(args.repo)

    with cli.catch_api_errors():
        return repo.create()
示例#3
0
文件: repo.py 项目: alphagov/ghtools
def get(args):
    """
    Print the JSON representation of the specified repository to STDOUT
    """
    repo = Repo(args.repo)

    with cli.catch_api_errors():
        return json.dumps(repo.get(), indent=2)
示例#4
0
文件: repo.py 项目: alphagov/ghtools
def delete(args):
    """
    Delete the specified repository
    """
    repo = Repo(args.repo)

    with cli.catch_api_errors():
        repo.delete()
示例#5
0
def status(args):
    """
    Set build status for a commit on GitHub
    """
    repo = Repo(args.repo)

    payload = {'state': args.state}

    if args.description is not None:
        payload['description'] = args.description

    if args.url is not None:
        payload['target_url'] = args.url

    if args.context is not None:
        payload['context'] = args.context

    with cli.catch_api_errors():
        res = repo.set_build_status(args.sha, payload)

    print(json.dumps(res.json(), indent=2))
示例#6
0
def status(args):
    """
    Set build status for a commit on GitHub
    """
    repo = Repo(args.repo)

    payload = {'state': args.state}

    if args.description is not None:
        payload['description'] = args.description

    if args.url is not None:
        payload['target_url'] = args.url

    if args.context is not None:
        payload['context'] = args.context

    with cli.catch_api_errors():
        res = repo.set_build_status(args.sha, payload)

    print(json.dumps(res.json(), indent=2))