def test_load_gitlab_config(): gitlab_config_path = os.path.join( os.path.dirname(__file__), 'gitlab_config_for_testing.py', ) obj = load_gitlab_config(gitlab_config_path) assert 'http://xxx' == obj.api_prefix assert 'testuser' == obj.username assert 'testpassword' == obj.password assert '12345' == obj.token assert 'testgroup' == obj.groupname assert '1234' == obj.groupid
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)