Skip to content

Commit 5ceee87

Browse files
authored
Merge 50ba3cb into aa08f84
2 parents aa08f84 + 50ba3cb commit 5ceee87

File tree

4 files changed

+127
-71
lines changed

4 files changed

+127
-71
lines changed

CHANGELOG.md

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,5 @@
11
# Changelog
22

3-
<!--
4-
5-
This should be updated on every PR.
6-
7-
We copy from here into the release notes.
8-
9-
-->
10-
11-
<!--
12-
Add next version above previous version but below this line using the template
13-
14-
## Next Version
15-
16-
VS Code v0.00.0
17-
18-
### New Features
19-
20-
- item
21-
22-
### Bug Fixes
23-
24-
- fix(socket): did this thing #321 @githubuser
25-
26-
### Documentation
27-
28-
- item
29-
30-
### Development
31-
32-
- item
33-
34-
-->
35-
36-
## Next Version
37-
38-
VS Code v0.00.0
39-
40-
### New Features
41-
42-
- item
43-
44-
### Bug Fixes
45-
46-
- Fix logout when using a base path (#3608)
47-
48-
### Documentation
49-
50-
- docs: add Pomerium #3424 @desimone
51-
- docs: fix confusing sentence in pull requests section #3460 @shiv-tyagi
52-
- docs: remove toc from changelog @oxy @jsjoeio
53-
- docs(MAINTAINING): add information about CHANGELOG #3467 @jsjoeio
54-
- docs: move release process to MAINTAINING.md #3441 @oxy @Prashant168
55-
- docs: format 'Caddy' from guide.md @PisecesPeng
56-
57-
### Development
58-
59-
- chore: cross-compile docker images with buildx #3166 @oxy
60-
- chore: update node to v14 #3458 @oxy
61-
- chore: update .gitignore #3557 @cuining
62-
- fix: use sufficient computational effort for password hash #3422 @jsjoeio
63-
- docs(CONTRIBUTING): add section on testing #3629 @jsjoeio
64-
65-
### Development
66-
67-
- fix(publish): update cdrci fork in brew-bump.sh #3468 @jsjoeio
68-
693
## 3.10.2
704

715
VS Code v1.56.1

docs/CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- [End-to-End Tests](#end-to-end-tests)
1616
- [Structure](#structure)
1717
- [Modifications to VS Code](#modifications-to-vs-code)
18+
- [Prepare CHANGELOG.md for releases.](#prepare-changelogmd-for-releases)
1819
- [Currently Known Issues](#currently-known-issues)
1920

2021
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -196,6 +197,21 @@ work as expected.
196197
If the functionality you're working on does NOT depend on code from VS Code, please
197198
move it out and into code-server.
198199

200+
### Prepare CHANGELOG.md for releases.
201+
202+
prepare_changelog.py does:
203+
204+
- extract merged PR´s from last release
205+
- Prepare CHANGELOG.md (needs manual editing to group the PRs)
206+
207+
the script depend on `gh` which must be installed.
208+
209+
example
210+
211+
```
212+
./prepare_changelog.py 3.10.3 1.56.1 3393
213+
```
214+
199215
### Currently Known Issues
200216

201217
- Creating custom VS Code extensions and debugging them doesn't work

docs/MAINTAINING.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,7 @@ The code-server project follows traditional [semantic versioning](ttps://semver.
8383

8484
### Changelog
8585

86-
To save time when creating a new release for code-server, we keep a running changelog at `CHANGELOG.md`.
87-
88-
If either author or reviewer of a PR believe the change should be mentioned in the `CHANGELOG`, then it should be added.
89-
90-
If there is not a "Next Version" when you modify `CHANGELOG`, please add it using the template you see near the top of `CHANGELOG`. You can use the suggested format: `<pr title> <pr #> <author> Example: `fix: Check the logged user instead of $USER #3330 @videlanicolas`
86+
To save time when creating a new release for code-server, we have a script that generates `CHANGELOG.md`.
9187

9288
## Release
9389

prepare_changelog.py

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/usr/bin/env python3
2+
"""Prepare CHANGELOG.md for a new release."""
3+
import os
4+
import sys
5+
import subprocess
6+
import json
7+
8+
AUTHOR="author"
9+
TITLE="title"
10+
PR="number"
11+
FEATURE="feature"
12+
FIX="fix"
13+
DOCS="docs"
14+
DEVELOPMENT="development"
15+
16+
17+
def gather_pr_list(repo="cdr/code-server", count=500):
18+
"""Use 'gh' to retrieve all new merged PR"""
19+
20+
cmd = [
21+
"gh", "pr", "list",
22+
"--state", "merged",
23+
"--repo", repo,
24+
"-L", str(count),
25+
"--json", "author,number,title"
26+
]
27+
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
28+
pr_dict = json.load(proc.stdout)
29+
for entry in pr_dict:
30+
entry[AUTHOR] = entry[AUTHOR]['login']
31+
entry[PR] = int(entry[PR])
32+
return pr_dict
33+
34+
35+
def generate_lines(pr_dict, last=0):
36+
"""Format PR entries as text lines, ready to go into CHANGELOG.md"""
37+
38+
def get_type(source) -> bool:
39+
"""Intelligent compare"""
40+
41+
for x in [FEATURE, FIX, DOCS]:
42+
source_prefix = source[:len(x)].casefold()
43+
if source_prefix == x:
44+
return x
45+
return DEVELOPMENT
46+
47+
result = {
48+
FEATURE: [],
49+
FIX: [],
50+
DOCS: [],
51+
DEVELOPMENT: [],
52+
}
53+
for entry in pr_dict:
54+
if entry[PR] <= last:
55+
continue
56+
line = f"- {entry[TITLE]} #{entry[PR]} {entry[AUTHOR]}\n"
57+
result[get_type(entry[TITLE])].append(line)
58+
return result
59+
60+
61+
def read_changelog():
62+
"""Read lines in CHANGELOG.md and skip white spaces"""
63+
with open("CHANGELOG.md") as f:
64+
content = f.readlines()
65+
del content[0]
66+
del content[0]
67+
return content
68+
69+
70+
def build_changelog(version, vscode_version, pr_lines, old_lines):
71+
"""Build lines in changelog and write new changelog"""
72+
73+
lines = [
74+
f"# Changelog\n\n## {version}\n\nVS Code {vscode_version}\n\n",
75+
]
76+
for content in [
77+
(FEATURE, "### New Features"),
78+
(FIX, "### Bug Fixes"),
79+
(DOCS, "### Documentation"),
80+
(DEVELOPMENT, "### Development"),
81+
]:
82+
lines.append(f"{content[1]}\n\n")
83+
lines.extend(pr_lines[content[0]])
84+
lines.append("\n")
85+
lines.extend(old_lines)
86+
with open("CHANGELOG.md", "w") as f:
87+
f.writelines(lines)
88+
89+
90+
def main(argv):
91+
"""Run the script."""
92+
if not os.path.isfile("CHANGELOG.md"):
93+
print("Run prepare_changelog.py from code-server root dir")
94+
return 1
95+
if len(argv) != 4:
96+
usage = "prepare_changelog.py <release> <vscode release> <last PR of previous release>"
97+
print(f"Usage\n {usage}")
98+
return 1
99+
version = argv[1]
100+
vscode_version = argv[2]
101+
last = int(argv[3])
102+
pr_dict = gather_pr_list()
103+
pr_lines = generate_lines(pr_dict, last)
104+
lines = read_changelog()
105+
build_changelog(version, vscode_version, pr_lines, lines)
106+
return 0
107+
108+
109+
if __name__ == "__main__":
110+
sys.exit(main(sys.argv))

0 commit comments

Comments
 (0)