[moblab] Script to find changes included in a release

Adding a script 'get_release_changes.py' that will
look through git logs of all of our relevant repos
and find the changes that are not common between
release R(n) and R(n-1), which is effectively the
list of new changes for R(n).

BUG=none
TEST=Testing that script shows the correct commits

Change-Id: Ic0aa3c14fe5c9c9b2febd2f304e06c622a96095f
Reviewed-on: https://chromium-review.googlesource.com/956608
Commit-Ready: Matt Mallett <mattmallett@chromium.org>
Tested-by: Matt Mallett <mattmallett@chromium.org>
Reviewed-by: Keith Haddow <haddowk@chromium.org>
diff --git a/scripts/get_release_changes.py b/scripts/get_release_changes.py
new file mode 100755
index 0000000..9b0540a
--- /dev/null
+++ b/scripts/get_release_changes.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import os
+import subprocess
+import re
+import sys
+
+usage = ('USAGE: %s <release_number>\n  '
+         '  <release_number> is RXX, R64, R65 etc') % sys.argv[0]
+
+if len(sys.argv) != 2:
+  print usage
+  exit(1)
+
+home = os.path.expanduser('~')
+trunk = '%s/trunk/src/' % home
+
+repos = [
+  'platform/moblab',
+  'third_party/autotest/files',
+  'overlays',
+  'third_party/whining',
+  'third_party/portage-stable',
+]
+
+try:
+  release_number_int = int(sys.argv[1][1:])
+except ValueError:
+  print usage
+  exit(1)
+
+def get_branch(release_number):
+  os.chdir('%s/platform/moblab' % trunk)
+  cmd = 'git branch -a | grep release-R%d' % release_number
+  return subprocess.check_output([cmd], shell=True).strip()
+
+release = get_branch(release_number_int)
+previous_release = get_branch(release_number_int -1)
+cmd = ("git --no-pager log --cherry --pretty=format:'%h - %s (%ae %cr)'"
+       ' {1}...{0} | '
+       "grep -E 'moblab|mattmallett|haddowk'").format(release, previous_release)
+
+for repo in repos:
+  repo_path = '%s%s' % (trunk, repo)
+  try:
+    os.chdir(repo_path)
+    commits = subprocess.check_output([cmd], shell=True)
+    print repo, '\n'
+    print commits
+    print '\n'
+  except Exception as e:
+    print repo, '\n'
+    print 'no changes', '\n'
+