Skip to content

Commit 879b8d8

Browse files
committedAug 20, 2017
Update changelog with RELEASE before building docs
1 parent 6710e58 commit 879b8d8

File tree

4 files changed

+76
-4
lines changed

4 files changed

+76
-4
lines changed
 

‎Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,11 @@ clean:
275275
find src tests -name "*.pyc" -delete
276276
find src tests -name "__pycache__" -delete
277277

278-
documentation: $(SPHINX_BUILD) docs/*.rst
279-
PYTHONPATH=src $(SPHINX_BUILD) -W -b html -d docs/_build/doctrees docs docs/_build/html
278+
.PHONY: RELEASE.rst
279+
RELEASE.rst:
280+
281+
documentation: $(SPHINX_BUILD) docs/*.rst RELEASE.rst
282+
scripts/build-documentation.sh $(SPHINX_BUILD) $(PY36)
280283

281284
doctest: $(SPHINX_BUILD) docs/*.rst
282285
PYTHONPATH=src $(SPHINX_BUILD) -W -b doctest -d docs/_build/doctrees docs docs/_build/html

‎scripts/build-documentation.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -x
6+
7+
SPHINX_BUILD=$1
8+
PYTHON=$2
9+
10+
HERE="$(dirname $0)"
11+
12+
cd "$HERE"/..
13+
14+
trap "git checkout docs/changes.rst src/hypothesis/version.py" EXIT
15+
16+
$PYTHON scripts/update-changelog-for-docs.py
17+
18+
export PYTHONPATH=src
19+
20+
$SPHINX_BUILD -W -b html -d docs/_build/doctrees docs docs/_build/html

‎scripts/hypothesistooling.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ def has_source_changes(version=None):
124124
]) != 0
125125

126126

127+
def has_uncommitted_changes(filename):
128+
return subprocess.call([
129+
'git', 'diff', '--exit-code', filename
130+
]) != 0
131+
132+
127133
def git(*args):
128134
subprocess.check_call(('git',) + args)
129135

@@ -247,7 +253,7 @@ def parse_release_file():
247253
return release_type, release_contents
248254

249255

250-
def update_for_pending_release():
256+
def update_changelog_and_version():
251257
global __version_info__
252258
global __version__
253259

@@ -313,10 +319,14 @@ def update_for_pending_release():
313319
with open(CHANGELOG_FILE, 'w') as o:
314320
o.write('\n'.join(new_changelog_parts))
315321

322+
323+
def update_for_pending_release():
324+
update_changelog_and_version()
325+
316326
git('rm', RELEASE_FILE)
317327
git('add', CHANGELOG_FILE, VERSION_FILE)
318328

319329
git(
320330
'commit',
321-
'-m', 'Bump version to %s and update changelog' % (new_version_string,)
331+
'-m', 'Bump version to %s and update changelog' % (__version__,)
322332
)

‎scripts/update-changelog-for-docs.py

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python
2+
3+
# coding=utf-8
4+
#
5+
# This file is part of Hypothesis, which may be found at
6+
# https://github.com/HypothesisWorks/hypothesis-python
7+
#
8+
# Most of this work is copyright (C) 2013-2017 David R. MacIver
9+
# (david@drmaciver.com), but it contains contributions by others. See
10+
# CONTRIBUTING.rst for a full list of people who may hold copyright, and
11+
# consult the git log if you need to determine who owns an individual
12+
# contribution.
13+
#
14+
# This Source Code Form is subject to the terms of the Mozilla Public License,
15+
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
16+
# obtain one at http://mozilla.org/MPL/2.0/.
17+
#
18+
# END HEADER
19+
20+
from __future__ import division, print_function, absolute_import
21+
22+
import os
23+
import sys
24+
25+
import hypothesistooling as tools
26+
27+
sys.path.append(os.path.dirname(__file__)) # noqa
28+
29+
30+
if __name__ == '__main__':
31+
if not tools.has_release():
32+
sys.exit(0)
33+
if tools.has_uncommitted_changes(tools.CHANGELOG_FILE):
34+
print(
35+
'Cannot build documentation with uncommitted changes to '
36+
'changelog and a pending release. Please commit your changes or '
37+
'delete your release file.')
38+
sys.exit(1)
39+
tools.update_changelog_and_version()

0 commit comments

Comments
 (0)