Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

generate-api: print component versions #3552

Merged
merged 3 commits into from
Aug 10, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions utilities/generate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
# $ python utilities/generate_api.py PATH_TO_ARTMAN_CONFIG_FILE ARTIFACT_NAME

import argparse
import collections
import io
import os
import re
import shutil
import subprocess

Expand All @@ -40,6 +42,33 @@
JAVA_GAPIC="java_gapic"
JAVA_DISCOGAPIC="java_discogapic"


def dump_versions(config_path):
print("Component versions:")

print(subprocess.check_output(['artman', '--version'], stderr=subprocess.STDOUT).strip())

print("googleapis %s" % get_git_repo_version(os.path.dirname(config_path)))

This comment was marked as spam.

This comment was marked as spam.

print("google-cloud-java %s" % get_git_repo_version(os.path.dirname(__file__)))

with io.open(os.path.expanduser("~/.artman/config.yaml"), encoding='UTF-8') as config_file:
artman_config_data = yaml.load(config_file, Loader=yaml.Loader)
toolkit_path = artman_config_data['local']['toolkit']
print("gapic_generator %s" % get_git_repo_version(toolkit_path))


def get_git_repo_version(path):

This comment was marked as spam.

This comment was marked as spam.

commit = subprocess.check_output(['git', '-C', path, 'rev-parse', 'HEAD']).strip()
suffix = ''

changes = subprocess.check_output(['git', '-C', path, 'diff', '--stat'])

if changes:
suffix = " (%s)" % changes.splitlines()[-1]

return ''.join([commit, suffix])


def run_generate_api(config_path, artifact_name, noisy=False):
""" Generate an API client library.

Expand Down Expand Up @@ -138,6 +167,8 @@ def main():
help='Don\'t print informational instructions')
args = parser.parse_args()

dump_versions(args.config_file)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.


run_generate_api(args.config_file, args.artifact_name, not args.quiet)

if __name__ == '__main__':
Expand Down