2 # Copyright © 2019-2020 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 """Generates release notes for a given version of mesa."""
34 from mako
.template
import Template
35 from mako
import exceptions
38 CURRENT_GL_VERSION
= '4.6'
39 CURRENT_VK_VERSION
= '1.2'
41 TEMPLATE
= Template(textwrap
.dedent("""\
46 Mesa ${this_version} is a new development release. People who are concerned
47 with stability and reliability should stick with a previous release or
48 wait for Mesa ${this_version[:-1]}1.
50 Mesa ${this_version} is a bug fix release which fixes bugs found since the ${previous_version} release.
53 Mesa ${this_version} implements the OpenGL ${gl_version} API, but the version reported by
54 glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
55 glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
56 Some drivers don't support all the features required in OpenGL ${gl_version}. OpenGL
57 ${gl_version} is **only** available if requested at context creation.
58 Compatibility contexts may report a lower version depending on each driver.
60 Mesa ${this_version} implements the Vulkan ${vk_version} API, but the version reported by
61 the apiVersion property of the VkPhysicalDeviceProperties struct
62 depends on the particular driver being used.
90 %for c, author_line in changes:
102 async def gather_commits(version
: str) -> str:
103 p
= await asyncio
.create_subprocess_exec(
104 'git', 'log', '--oneline', f
'mesa-{version}..', '--grep', r
'Closes: \(https\|#\).*',
105 stdout
=asyncio
.subprocess
.PIPE
)
106 out
, _
= await p
.communicate()
107 assert p
.returncode
== 0, f
"git log didn't work: {version}"
108 return out
.decode().strip()
111 async def gather_bugs(version
: str) -> typing
.List
[str]:
112 commits
= await gather_commits(version
)
114 issues
: typing
.List
[str] = []
115 for commit
in commits
.split('\n'):
116 sha
, message
= commit
.split(maxsplit
=1)
117 p
= await asyncio
.create_subprocess_exec(
118 'git', 'log', '--max-count', '1', r
'--format=%b', sha
,
119 stdout
=asyncio
.subprocess
.PIPE
)
120 _out
, _
= await p
.communicate()
121 out
= _out
.decode().split('\n')
122 for line
in reversed(out
):
123 if line
.startswith('Closes:'):
124 bug
= line
.lstrip('Closes:').strip()
127 raise Exception('No closes found?')
128 if bug
.startswith('h'):
129 # This means we have a bug in the form "Closes: https://..."
130 issues
.append(os
.path
.basename(urllib
.parse
.urlparse(bug
).path
))
132 issues
.append(bug
.lstrip('#'))
134 loop
= asyncio
.get_event_loop()
135 async with aiohttp
.ClientSession(loop
=loop
) as session
:
136 results
= await asyncio
.gather(*[get_bug(session
, i
) for i
in issues
])
137 typing
.cast(typing
.Tuple
[str, ...], results
)
144 async def get_bug(session
: aiohttp
.ClientSession
, bug_id
: str) -> str:
145 """Query gitlab to get the name of the issue that was closed."""
146 # Mesa's gitlab id is 176,
147 url
= 'https://gitlab.freedesktop.org/api/v4/projects/176/issues'
148 params
= {'iids[]': bug_id
}
149 async with session
.get(url
, params
=params
) as response
:
150 content
= await response
.json()
151 return content
[0]['title']
154 async def get_shortlog(version
: str) -> str:
155 """Call git shortlog."""
156 p
= await asyncio
.create_subprocess_exec('git', 'shortlog', f
'mesa-{version}..',
157 stdout
=asyncio
.subprocess
.PIPE
)
158 out
, _
= await p
.communicate()
159 assert p
.returncode
== 0, 'error getting shortlog'
160 assert out
is not None, 'just for mypy'
164 def walk_shortlog(log
: str) -> typing
.Generator
[typing
.Tuple
[str, bool], None, None]:
165 for l
in log
.split('\n'):
166 if l
.startswith(' '): # this means we have a patch description
167 yield l
.lstrip(), False
172 def calculate_next_version(version
: str, is_point
: bool) -> str:
173 """Calculate the version about to be released."""
175 version
= version
.split('-')[0]
177 base
= version
.split('.')
178 base
[2] = str(int(base
[2]) + 1)
179 return '.'.join(base
)
183 def calculate_previous_version(version
: str, is_point
: bool) -> str:
184 """Calculate the previous version to compare to.
186 In the case of -rc to final that verison is the previous .0 release,
187 (19.3.0 in the case of 20.0.0, for example). for point releases that is
188 the last point release. This value will be the same as the input value
189 for a point release, but different for a major release.
192 version
= version
.split('-')[0]
195 base
= version
.split('.')
197 base
[0] = str(int(base
[0]) - 1)
200 base
[1] = str(int(base
[1]) - 1)
201 return '.'.join(base
)
204 def get_features(is_point_release
: bool) -> typing
.Generator
[str, None, None]:
205 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'relnotes' / 'new_features.txt'
208 print("WARNING: new features being introduced in a point release", file=sys
.stderr
)
209 with p
.open('rt') as f
:
218 async def main() -> None:
219 v
= pathlib
.Path(__file__
).parent
.parent
/ 'VERSION'
220 with v
.open('rt') as f
:
221 raw_version
= f
.read().strip()
222 is_point_release
= '-rc' not in raw_version
223 assert '-devel' not in raw_version
, 'Do not run this script on -devel'
224 version
= raw_version
.split('-')[0]
225 previous_version
= calculate_previous_version(version
, is_point_release
)
226 this_version
= calculate_next_version(version
, is_point_release
)
227 today
= datetime
.date
.today()
228 header
= f
'Mesa {this_version} Release Notes / {today}'
229 header_underline
= '=' * len(header
)
231 shortlog
, bugs
= await asyncio
.gather(
232 get_shortlog(previous_version
),
233 gather_bugs(previous_version
),
236 final
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'relnotes' / f
'{this_version}.rst'
237 with final
.open('wt') as f
:
239 f
.write(TEMPLATE
.render(
240 bugfix
=is_point_release
,
242 changes
=walk_shortlog(shortlog
),
243 features
=get_features(is_point_release
),
244 gl_version
=CURRENT_GL_VERSION
,
245 this_version
=this_version
,
247 header_underline
=header_underline
,
248 previous_version
=previous_version
,
249 vk_version
=CURRENT_VK_VERSION
,
252 print(exceptions
.text_error_template().render())
255 if __name__
== "__main__":
256 loop
= asyncio
.get_event_loop()
257 loop
.run_until_complete(main())