Keep sections in importance order by hugovk · Pull Request #75 · python/blurb · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
1 change: 1 addition & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target-version = "py310"
fix = true

[format]
preview = true
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.0

* Keep sections in importance order by @hugovk in https://github.com/python/blurb/pull/75

## 2.1.0

- Add the `-i` / `--issue` option to the 'blurb add' command.
Expand Down
33 changes: 22 additions & 11 deletions src/blurb/_utils/globs.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,29 @@
def glob_blurbs(version: str) -> list[str]:
filenames = []
base = os.path.join('Misc', 'NEWS.d', version)

if version != 'next':
wildcard = f'{base}.rst'
filenames.extend(glob.glob(wildcard))
else:
sanitized_sections = set(map(sanitize_section, sections))
sanitized_sections |= set(map(sanitize_section_legacy, sections))
for section in sanitized_sections:
wildcard = os.path.join(base, section, '*.rst')
entries = glob.glob(wildcard)
deletables = [x for x in entries if x.endswith('/README.rst')]
for filename in deletables:
entries.remove(filename)
filenames.extend(entries)
filenames.sort(reverse=True, key=next_filename_unsanitize_sections)
return filenames

for section in sections:
entries = []
seen_dirs = set()
for dir_name in (
sanitize_section(section),
sanitize_section_legacy(section),
):
if dir_name in seen_dirs:
continue

seen_dirs.add(dir_name)
wildcard = os.path.join(base, dir_name, '*.rst')
for entry in glob.glob(wildcard):
if not entry.endswith('/README.rst'):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm won't this fail on Windows? But this is a prexisting issue.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I saw that too but kept this PR focused. And this function is only called by the release process, which only supports Linux and macOS, which is enough for all the RMs.

entries.append(entry)

entries.sort(reverse=True, key=next_filename_unsanitize_sections)
filenames.extend(entries)

return filenames
30 changes: 30 additions & 0 deletions tests/test_utils_globs.py
Loading