##// END OF EJS Templates
run darker
dswij -
Show More
@@ -7,25 +7,24 b' whatsnew/development.rst (chronologically ordered), and deletes the snippets.'
7 7
8 8 import io
9 9 import sys
10 from pathlib import Path
10 from pathlib import Path
11 11 from subprocess import check_call, check_output
12 12
13 13 repo_root = Path(__file__).resolve().parent.parent
14 whatsnew_dir = repo_root / 'docs' / 'source' / 'whatsnew'
15 pr_dir = whatsnew_dir / 'pr'
16 target = whatsnew_dir / 'development.rst'
14 whatsnew_dir = repo_root / "docs" / "source" / "whatsnew"
15 pr_dir = whatsnew_dir / "pr"
16 target = whatsnew_dir / "development.rst"
17 17
18 18 FEATURE_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. FEATURE INSERTION POINT."
19 19 INCOMPAT_MARK = ".. DO NOT EDIT THIS LINE BEFORE RELEASE. INCOMPAT INSERTION POINT."
20 20
21 21 # 1. Collect the whatsnew snippet files ---------------------------------------
22 22
23 files = set(pr_dir.glob('*.rst'))
23 files = set(pr_dir.glob("*.rst"))
24 24 # Ignore explanatory and example files
25 files.difference_update({pr_dir / f for f in {
26 'incompat-switching-to-perl.rst',
27 'antigravity-feature.rst'}
28 })
25 files.difference_update(
26 {pr_dir / f for f in {"incompat-switching-to-perl.rst", "antigravity-feature.rst"}}
27 )
29 28
30 29 if not files:
31 30 print("No automatic update available for what's new")
@@ -33,30 +32,31 b' if not files:'
33 32
34 33
35 34 def getmtime(f):
36 return check_output(['git', 'log', '-1', '--format="%ai"', '--', f])
35 return check_output(["git", "log", "-1", '--format="%ai"', "--", f])
36
37 37
38 38 files = sorted(files, key=getmtime)
39 39
40 40 features, incompats = [], []
41 41 for path in files:
42 with io.open(path, encoding='utf-8') as f:
42 with io.open(path, encoding="utf-8") as f:
43 43 try:
44 44 content = f.read().rstrip()
45 45 except Exception as e:
46 46 raise Exception('Error reading "{}"'.format(f)) from e
47 47
48 if path.name.startswith('incompat-'):
48 if path.name.startswith("incompat-"):
49 49 incompats.append(content)
50 50 else:
51 51 features.append(content)
52 52
53 53 # Put the insertion markers back on the end, so they're ready for next time.
54 feature_block = '\n\n'.join(features + [FEATURE_MARK])
55 incompat_block = '\n\n'.join(incompats + [INCOMPAT_MARK])
54 feature_block = "\n\n".join(features + [FEATURE_MARK])
55 incompat_block = "\n\n".join(incompats + [INCOMPAT_MARK])
56 56
57 57 # 2. Update the target file ---------------------------------------------------
58 58
59 with io.open(target, encoding='utf-8') as f:
59 with io.open(target, encoding="utf-8") as f:
60 60 content = f.read()
61 61
62 62 assert content.count(FEATURE_MARK) == 1
@@ -66,16 +66,16 b' content = content.replace(FEATURE_MARK, feature_block)'
66 66 content = content.replace(INCOMPAT_MARK, incompat_block)
67 67
68 68 # Clean trailing whitespace
69 content = '\n'.join(l.rstrip() for l in content.splitlines())
69 content = "\n".join(l.rstrip() for l in content.splitlines())
70 70
71 with io.open(target, 'w', encoding='utf-8') as f:
71 with io.open(target, "w", encoding="utf-8") as f:
72 72 f.write(content)
73 73
74 74 # 3. Stage the changes in git -------------------------------------------------
75 75
76 76 for file in files:
77 check_call(['git', 'rm', file])
77 check_call(["git", "rm", file])
78 78
79 check_call(['git', 'add', target])
79 check_call(["git", "add", target])
80 80
81 81 print("Merged what's new changes. Check the diff and commit the change.")
General Comments 0
You need to be logged in to leave comments. Login now