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)
def create(args): """ Create a repo with specified name """ repo = Repo(args.repo) with cli.catch_api_errors(): return repo.create()
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)
def delete(args): """ Delete the specified repository """ repo = Repo(args.repo) with cli.catch_api_errors(): repo.delete()
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))