Skip to content

Commit 1f59ac9

Browse files
authored
Fix PR link generation in new-change and bug in render command (#2767)
- Generate correct /pull/ URLs for PR references instead of /issues/ - Fix template field name from 'pull request:' to 'pull requests:' - Fix version parsing check in render command
1 parent 8ab8639 commit 1f59ac9

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "bugfix",
3+
"description": "Fix PR link generation in new-change and render command",
4+
"pull_requests": [
5+
"[#2767](https://github.com/smithy-lang/smithy/pull/2767)"
6+
]
7+
}

.changes/smithy_changelog/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def from_path(cls, path: Path) -> Self:
141141
The file name is expected to be in the form `major.minor.patch.extention`.
142142
"""
143143
parts = path.name.split(".", 3)
144-
if len(parts) != 3:
144+
if len(parts) != 4:
145145
raise Exception(
146146
f"Invalid version. Expected `major.minor.patch.extension` "
147147
f"(e.g. `1.2.3.json`), but found: {path.name}"
@@ -224,7 +224,9 @@ def write(self, file: Path | None = None) -> str:
224224
225225
:returns: The JSON representation of the release as a string.
226226
"""
227-
contents = json.dumps(asdict(self), indent=2, default=str) + "\n"
227+
data = asdict(self)
228+
data["version"] = str(self.version)
229+
contents = json.dumps(data, indent=2, default=str) + "\n"
228230
if file is not None:
229231
file.write_text(contents)
230232
return contents

.changes/smithy_changelog/new.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
type: {change_type}
2424
2525
# (Optional)
26-
# A link to the GitHub pull request that implments the feature. You can use GitHub
26+
# A link to the GitHub pull request that implements the feature. You can use GitHub
2727
# sytle references, which will automatically be replaced with the correct link.
28-
pull request: {pull_requests}
28+
pull requests: {pull_requests}
2929
3030
# A brief description of the change. You can use GitHub style references to issues such
3131
# as "fixes #489", "smithy-lang/smithy#100", etc. These will get automatically replaced
@@ -116,16 +116,20 @@ def get_values_from_editor(
116116

117117

118118
def replace_issue_references(change: Change, repo_name: str):
119-
def linkify(match: re.Match[str]):
119+
def linkify_issue(match: re.Match[str]):
120120
number = match.group()[1:]
121121
return f"[{match.group()}](https://github.com/{repo_name}/issues/{number})"
122122

123-
new_description = re.sub(r"#\d+", linkify, change.description)
123+
def linkify_pr(match: re.Match[str]):
124+
number = match.group()[1:]
125+
return f"[{match.group()}](https://github.com/{repo_name}/pull/{number})"
126+
127+
new_description = re.sub(r"#\d+", linkify_issue, change.description)
124128
change.description = new_description
125129

126130
if change.pull_requests:
127131
change.pull_requests = [
128-
re.sub(r"#\d+", linkify, pr) for pr in change.pull_requests
132+
re.sub(r"#\d+", linkify_pr, pr) for pr in change.pull_requests
129133
]
130134

131135

0 commit comments

Comments
 (0)