def get_travis_files_content(full_name, github_token, config): """ Return the content of the files that will be committed to the repo. """ info = { 'GIT_NAME': GIT_NAME, 'GIT_EMAIL': GIT_EMAIL, 'GH_TOKEN': github_token } user_pages = github_utils.is_user_pages(full_name) travis_files = [ { 'name': SCRIPT, 'content': travis_utils.get_script_contents(SCRIPT, config), 'message': ( 'Add build and deploy script (via Statiki).\n\n[skip ci]' ), }, { 'name': '.travis.yml', 'content': travis_utils.get_yaml_contents( full_name, SCRIPT, info, user_pages ), 'message': 'Add .travis.yml (via Statiki).', }, ] return travis_files
def manage(): full_name = request.form.get('full_name', '') data = dict(parse_qsl(request.form.get('data', ''))) repo_name = ( '' if github_utils.is_user_pages(full_name) else full_name.split('/', 1)[-1] ) github_token = current_user.github_token travis_token = current_user.travis_token # If repo not listed in travis, sync repo_id = travis_utils.get_repo_id(full_name, travis_token) if repo_id is None: travis_utils.sync_with_github(travis_token) repo_id = travis_utils.get_repo_id(full_name, travis_token) if repo_id is None: message = messages.NO_SUCH_REPO_FOUND return jsonify(dict(message=message)) enabled = travis_utils.enable_hook(repo_id, travis_token) created = create_travis_files(full_name, github_token, data) response = get_display_response(enabled, created) response['message'] %= dict(USER=current_user.username, REPO=repo_name) return jsonify(response)
def test_should_detect_non_user_pages_repo(self): self.assertFalse( github_utils.is_user_pages('punchagan/baali.github.io') )
def test_should_detect_user_pages_repo(self): self.assertTrue( github_utils.is_user_pages('punchagan/punchagan.github.io') )