def test_github_repo_id(): repo_config_path = os.path.join( os.path.dirname(__file__), 'repo_config_for_testing.py', ) repo_ids = load_repo_config(repo_config_path) assert 2 == len(repo_ids) test_id = repo_ids[0] assert REPO_ID_TYPE_GITHUB == test_id.repo_id_type assert 'huntzhan' == test_id.owner assert 'easy-fork' == test_id.repo assert 'huntzhan/easy-fork' == test_id.fullname assert 'https://github.com/huntzhan/easy-fork.git' == test_id.url
def entry_point(): args = docopt(CLI_DOC) print(args) if args['search-repo']: items = search_repos( args['<language>'], args['<stars_lower_bound>'], args['<stars_upper_bound>'], ) # simple print full names. for item in items: print("'{0}'".format(item['full_name'])) return 0 gitlab_config = load_gitlab_config(args['--gitlab-config']) repo_ids = load_repo_config(args['--repo-config']) gitlab_project_handler = GitLabProjectAPIHandler(gitlab_config) if args['view-names-mapping']: for repo_id in repo_ids: success, url = gitlab_project_handler.check_existence( repo_id, auto_info=False, ) template = "| [{0}]({1}) | `{2}` |" msg = template.format( repo_id.fullname, repo_id.url, url if success else 'Not Forked Yet.', ) print(msg) return 0 local_repos_dir = os.getcwd() for repo_id in repo_ids: # download. repo_dir = git_clone_to_dir( repo_id.repo, repo_id.url, local_repos_dir, ) if repo_dir is None: print('Skipping {0}'.format(repo_id.fullname)) continue # create project in gitlab. remote_url = gitlab_project_handler.create_project(repo_id) # configure local git repo and push. # git_track_all_branches(repo_dir) git_push(repo_dir, 'git-oa', remote_url)