OLD | NEW |
1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 | 124 |
125 def current_build_link(host): | 125 def current_build_link(host): |
126 """Returns a link to the current job if running on buildbot, or None.""" | 126 """Returns a link to the current job if running on buildbot, or None.""" |
127 master_name = host.environ.get('BUILDBOT_MASTERNAME') | 127 master_name = host.environ.get('BUILDBOT_MASTERNAME') |
128 builder_name = host.environ.get('BUILDBOT_BUILDERNAME') | 128 builder_name = host.environ.get('BUILDBOT_BUILDERNAME') |
129 build_number = host.environ.get('BUILDBOT_BUILDNUMBER') | 129 build_number = host.environ.get('BUILDBOT_BUILDNUMBER') |
130 if not (master_name and builder_name and build_number): | 130 if not (master_name and builder_name and build_number): |
131 return None | 131 return None |
132 return 'https://build.chromium.org/p/%s/builders/%s/builds/%s' % (master_nam
e, builder_name, build_number) | 132 return 'https://build.chromium.org/p/%s/builders/%s/builds/%s' % (master_nam
e, builder_name, build_number) |
| 133 |
| 134 |
| 135 def filter_latest_builds(builds): |
| 136 """Filters Build objects to include only the latest for each builder. |
| 137 |
| 138 Args: |
| 139 builds: A collection of Build objects. |
| 140 |
| 141 Returns: |
| 142 A list of Build objects; only one Build object per builder name. If |
| 143 there are only Builds with no build number, then one is kept; if there |
| 144 are Builds with build numbers, then the one with the highest build |
| 145 number is kept. |
| 146 """ |
| 147 latest_builds = {} |
| 148 for build in builds: |
| 149 builder = build.builder_name |
| 150 if builder not in latest_builds or build.build_number > latest_builds[bu
ilder].build_number: |
| 151 latest_builds[builder] = build |
| 152 return sorted(latest_builds.values()) |
OLD | NEW |