lookup_pull.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env python
  2. # Copyright 2015 The Kubernetes Authors.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # Script to print out PR info in release note format.
  16. import json
  17. import sys
  18. import urllib2
  19. PULLQUERY=("https://api.github.com/repos/"
  20. "GoogleCloudPlatform/kubernetes/pulls/{pull}")
  21. LOGIN="login"
  22. TITLE="title"
  23. USER="user"
  24. def print_pulls(pulls):
  25. for pull in pulls:
  26. d = json.loads(urllib2.urlopen(PULLQUERY.format(pull=pull)).read())
  27. print "* {title} #{pull} ({author})".format(
  28. title=d[TITLE], pull=pull, author=d[USER][LOGIN])
  29. if __name__ == "__main__":
  30. if len(sys.argv) < 2:
  31. print ("Usage: {cmd} <pulls>...: Prints out short " +
  32. "markdown description for PRs appropriate for release notes.")
  33. sys.exit(1)
  34. print_pulls(sys.argv[1:])