def update(filepath, github_account): """Updates the google-api-go-client repository. Args: filepath (str): the directory to work in. github_account (GitHubAccount): the GitHub account to commit with. """ env = os.environ.copy() env['GO111MODULE'] = 'on' repo = _git.clone('https://code.googlesource.com/google-api-go-client', join(filepath, 'google-api-go-client')) generator_filepath = join(repo.filepath, 'google-api-go-generator') check_output(['make', 'all'], cwd=generator_filepath, env=env) repo.add(['.']) added, deleted, updated = set(), set(), set() status_to_ids = { _git.Status.ADDED: added, _git.Status.DELETED: deleted, _git.Status.UPDATED: updated } for filename, status in repo.diff_name_status(): match = _NAME_VERSION_RE.match(filename) if not match: continue name_version = '{}/{}'.format(match.group(1), match.group(2)) status_to_ids.get(status, set()).add(name_version) if not any([added, deleted, updated]): return check_output(['go', 'test', './...'], cwd=repo.filepath, env=env) subject = 'all: autogenerated update ({})'.format(date.today().isoformat()) commitmsg = _commit_message.build(added, deleted, updated, subject=subject) repo.commit(commitmsg, github_account.name, github_account.email) repo.push(remote=_REMOTE_URL, nokeycheck=True)
def update(filepath, github_account, discovery_documents): """Updates the google-api-php-client-services repository. Args: filepath (str): the directory to work in. github_account (GitHubAccount): the GitHub account to commit with. discovery_documents (dict(str, str)): a map of API IDs to Discovery document filenames to generate from. """ repo = _git.clone_from_github( _REPO_PATH, join(filepath, _REPO_NAME), github_account=github_account) venv_filepath = join(repo.filepath, 'venv') check_output(['virtualenv', venv_filepath, '-p', 'python2.7']) # The PHP client library generator is published in the # "google-apis-client-generator" package. check_output([join(venv_filepath, 'bin/pip'), 'install', 'google-apis-client-generator==1.6.1']) added, updated = _generate_and_commit_all_clients( repo, venv_filepath, discovery_documents) commit_count = len(added) + len(updated) if commit_count == 0: return _run_tests(repo) repo.soft_reset('HEAD~{}'.format(commit_count)) commitmsg = _commit_message.build(added, None, updated) repo.commit(commitmsg, github_account.name, github_account.email) repo.push()
def test_build_added_deleted_updated(date_mock): date_mock.today.return_value.isoformat.return_value = '2000-01-01' added = {'foo:v1', 'foo:v2'} deleted = {'bar:v1', 'bar:v2'} updated = {'baz:v1', 'baz:v2'} commitmsg = _commit_message.build(added, deleted, updated) assert commitmsg == ('Autogenerated update (2000-01-01)\n' '\n' 'Add:\n' '- foo:v1\n' '- foo:v2\n' '\n' 'Delete:\n' '- bar:v1\n' '- bar:v2\n' '\n' 'Update:\n' '- baz:v1\n' '- baz:v2')
def update(filepath, github_account): """Updates the google-api-nodejs-client repository. Args: filepath (str): the directory to work in. github_account (GitHubAccount): the GitHub account to commit with. """ repo = _git.clone_from_github( _REPO_PATH, join(filepath, _REPO_NAME), github_account=github_account) _install_dependencies(repo) added, deleted, updated = _generate_all_clients(repo) if not any([added, deleted, updated]): return _build(repo) _run_tests(repo) commitmsg = _commit_message.build(added, deleted, updated) repo.add(['apis']) repo.commit(commitmsg, github_account.name, github_account.email) repo.push()
def update(filepath, github_account): """Updates the google-api-ruby-client repository. Args: filepath (str): the directory to work in. discovery_documents (dict(str, str)): a map of API IDs to Discovery document filenames to generate from. github_account (GitHubAccount): the GitHub account to commit with. """ repo = _git.clone_from_github(_REPO_PATH, join(filepath, _REPO_NAME), github_account=github_account) _install_dependencies(repo) added, deleted, updated = _generate_all_clients(repo) if not any([added, deleted, updated]): return _run_tests(repo) commitmsg = _commit_message.build(added, deleted, updated) repo.add(['api_names_out.yaml', 'generated']) repo.commit(commitmsg, github_account.name, github_account.email) repo.push()
def test_build_updated_subject(): updated = {'baz:v1'} commitmsg = _commit_message.build(None, None, updated, subject='X') assert commitmsg == ('X\n' '\n' 'Update:\n' '- baz:v1')
def test_build_deleted_subject(): deleted = {'bar:v1'} commitmsg = _commit_message.build(None, deleted, None, subject='X') assert commitmsg == ('X\n' '\n' 'Delete:\n' '- bar:v1')
def test_build_added_subject(): added = {'foo:v1'} commitmsg = _commit_message.build(added, None, None, subject='X') assert commitmsg == ('X\n' '\n' 'Add:\n' '- foo:v1')
def test_build_subject(): commitmsg = _commit_message.build(None, None, None, subject='X') assert commitmsg == 'X'
def test_build_none(date_mock): date_mock.today.return_value.isoformat.return_value = '2000-01-01' commitmsg = _commit_message.build(None, None, None) assert commitmsg == 'Autogenerated update (2000-01-01)'