1ffe3c632Sopenharmony_ci#!/usr/bin/env python
2ffe3c632Sopenharmony_ci
3ffe3c632Sopenharmony_ci"""Generates a friendly list of changes per language since the last release."""
4ffe3c632Sopenharmony_ci
5ffe3c632Sopenharmony_ciimport sys
6ffe3c632Sopenharmony_ciimport os
7ffe3c632Sopenharmony_ci
8ffe3c632Sopenharmony_ciclass Language(object):
9ffe3c632Sopenharmony_ci  def __init__(self, name, pathspec):
10ffe3c632Sopenharmony_ci    self.name = name
11ffe3c632Sopenharmony_ci    self.pathspec = pathspec
12ffe3c632Sopenharmony_ci
13ffe3c632Sopenharmony_cilanguages = [
14ffe3c632Sopenharmony_ci  Language("C++", [
15ffe3c632Sopenharmony_ci      "':(glob)src/google/protobuf/*'",
16ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/cpp",
17ffe3c632Sopenharmony_ci      "src/google/protobuf/io",
18ffe3c632Sopenharmony_ci      "src/google/protobuf/util",
19ffe3c632Sopenharmony_ci      "src/google/protobuf/stubs",
20ffe3c632Sopenharmony_ci  ]),
21ffe3c632Sopenharmony_ci  Language("Java", [
22ffe3c632Sopenharmony_ci      "java",
23ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/java",
24ffe3c632Sopenharmony_ci  ]),
25ffe3c632Sopenharmony_ci  Language("Python", [
26ffe3c632Sopenharmony_ci      "python",
27ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/python",
28ffe3c632Sopenharmony_ci  ]),
29ffe3c632Sopenharmony_ci  Language("JavaScript", [
30ffe3c632Sopenharmony_ci      "js",
31ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/js",
32ffe3c632Sopenharmony_ci  ]),
33ffe3c632Sopenharmony_ci  Language("PHP", [
34ffe3c632Sopenharmony_ci      "php",
35ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/php",
36ffe3c632Sopenharmony_ci  ]),
37ffe3c632Sopenharmony_ci  Language("Ruby", [
38ffe3c632Sopenharmony_ci      "ruby",
39ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/ruby",
40ffe3c632Sopenharmony_ci  ]),
41ffe3c632Sopenharmony_ci  Language("Csharp", [
42ffe3c632Sopenharmony_ci      "csharp",
43ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/csharp",
44ffe3c632Sopenharmony_ci  ]),
45ffe3c632Sopenharmony_ci  Language("Objective C", [
46ffe3c632Sopenharmony_ci      "objectivec",
47ffe3c632Sopenharmony_ci      "src/google/protobuf/compiler/objectivec",
48ffe3c632Sopenharmony_ci  ]),
49ffe3c632Sopenharmony_ci]
50ffe3c632Sopenharmony_ci
51ffe3c632Sopenharmony_ciif len(sys.argv) < 2:
52ffe3c632Sopenharmony_ci  print("Usage: generate_changelog.py <previous release>")
53ffe3c632Sopenharmony_ci  sys.exit(1)
54ffe3c632Sopenharmony_ci
55ffe3c632Sopenharmony_ciprevious = sys.argv[1]
56ffe3c632Sopenharmony_ci
57ffe3c632Sopenharmony_cifor language in languages:
58ffe3c632Sopenharmony_ci  print(language.name)
59ffe3c632Sopenharmony_ci  sys.stdout.flush()
60ffe3c632Sopenharmony_ci  os.system(("git log --pretty=oneline --abbrev-commit %s...HEAD %s | " +
61ffe3c632Sopenharmony_ci             "sed -e 's/^/ - /'") % (previous, " ".join(language.pathspec)))
62ffe3c632Sopenharmony_ci  print("")
63ffe3c632Sopenharmony_ci
64ffe3c632Sopenharmony_ciprint("To view a commit on GitHub: " +
65ffe3c632Sopenharmony_ci      "https://github.com/protocolbuffers/protobuf/commit/<commit id>")
66