|
20 | 20 | # $ python utilities/generate_api.py PATH_TO_ARTMAN_CONFIG_FILE ARTIFACT_NAME
|
21 | 21 |
|
22 | 22 | import argparse
|
| 23 | +import collections |
23 | 24 | import io
|
24 | 25 | import os
|
| 26 | +import re |
25 | 27 | import shutil
|
26 | 28 | import subprocess
|
27 | 29 |
|
|
40 | 42 | JAVA_GAPIC="java_gapic"
|
41 | 43 | JAVA_DISCOGAPIC="java_discogapic"
|
42 | 44 |
|
| 45 | +def get_git_repo_version(path): |
| 46 | + commit = subprocess.check_output(['git', '-C', path, 'rev-parse', 'HEAD']).strip() |
| 47 | + suffix = '' |
| 48 | + |
| 49 | + changes = subprocess.check_output(['git', '-C', path, 'diff', '--stat']) |
| 50 | + |
| 51 | + if changes: |
| 52 | + suffix = " ({})".format(changes.splitlines()[-1]) |
| 53 | + |
| 54 | + return ''.join([commit, suffix]) |
| 55 | + |
| 56 | + |
| 57 | +def dump_versions(googleapis=None, discovery_repo=None): |
| 58 | + print("Component versions:") |
| 59 | + |
| 60 | + print(subprocess.check_output(['artman', '--version'], stderr=subprocess.STDOUT).strip()) |
| 61 | + |
| 62 | + with io.open(os.path.expanduser("~/.artman/config.yaml"), encoding='UTF-8') as config_file: |
| 63 | + artman_config_data = yaml.load(config_file, Loader=yaml.Loader) |
| 64 | + toolkit_path = artman_config_data['local']['toolkit'] |
| 65 | + print("gapic_generator {}".format(get_git_repo_version(toolkit_path))) |
| 66 | + |
| 67 | + print("google-cloud-java {}".format(get_git_repo_version(os.path.dirname(__file__)))) |
| 68 | + |
| 69 | + if googleapis: |
| 70 | + print("googleapis {}".format(get_git_repo_version(googleapis))) |
| 71 | + |
| 72 | + if discovery_repo: |
| 73 | + print("discovery_repo {}".format(get_git_repo_version(discovery_repo))) |
| 74 | + |
| 75 | + |
43 | 76 | def run_generate_api(config_path, artifact_name, noisy=False):
|
44 | 77 | """ Generate an API client library.
|
45 | 78 |
|
@@ -138,6 +171,9 @@ def main():
|
138 | 171 | help='Don\'t print informational instructions')
|
139 | 172 | args = parser.parse_args()
|
140 | 173 |
|
| 174 | + if not args.quiet: |
| 175 | + dump_versions(googleapis=os.path.dirname(args.config_file)) |
| 176 | + |
141 | 177 | run_generate_api(args.config_file, args.artifact_name, not args.quiet)
|
142 | 178 |
|
143 | 179 | if __name__ == '__main__':
|
|
0 commit comments