Skip to content

Allow the GH issue + Section as --flags and take news via stdin #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,9 @@ ENV/

# hatch-vcs
src/*/_version.py

*.bak
*.swp

CLAUDE.local.md
.claude/*
Copy link
Member

Choose a reason for hiding this comment

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

No objection to adding these here, but you may find it easier to add them a personal, global .gitignore.

8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.3
hooks:
- id: ruff-check
args: [--exit-non-zero-on-fix]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 2.1.0 (unreleased)

* Add automation support to `blurb add` command:
* New `--issue` option to specify GitHub issue number (supports URLs and various formats)
* New `--section` option to specify NEWS section (with smart case-insensitive matching)
* New `--rst-on-stdin` option to read entry content from stdin
* Useful for CI systems and automated tools
* Uses `cyclopts` for command-line parsing instead of rolling our own to reduce our code size, this changes the help format and brings in a dependency.

## 2.0.0

* Move 'blurb test' subcommand into test suite by @hugovk in https://github.com/python/blurb/pull/37
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,30 @@ It opens a text editor on a template; you edit the
file, save, and exit. **blurb** then stores the file
in the correct place, and stages it in Git for you.

#### Automation support

For automated tools and CI systems, `blurb add` supports non-interactive operation:

```bash
# Add a blurb entry from stdin
echo 'Added beans to the :mod:`spam` module.' | blurb add \
--issue 123456 \
--section Library \
--rst-on-stdin
```

When using `--rst-on-stdin`, both `--issue` and `--section` are required.

The `--issue` parameter accepts various formats:
- Issue number: `--issue 12345`
- With gh- prefix: `--issue gh-12345`
- GitHub URL: `--issue https://github.com/python/cpython/issues/12345`

The `--section` parameter supports smart matching:
- Case insensitive: `--section library` or `--section LIBRARY`
- Partial matching: `--section lib` (matches "Library")
- Common aliases: `--section api` (matches "C API"), `--section builtin` (matches "Core and Builtins")

Comment on lines +80 to +103
Copy link
Member

Choose a reason for hiding this comment

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

This adds a new "Automation support" section; this is fine.

But then it continues with the usual manual instructions.

Let's either move the Automation support" section below the manual stuff, or add another header just here.

The template for the `blurb add` message looks like this:

#
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ classifiers = [
dynamic = [
"version",
]
dependencies = [
"cyclopts>=3",
]
Comment on lines +33 to +35
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to avoid an external dependency here, blurb has a nice property currently of only using the standard library, meaning that we don't need to think about the maintenence or security of any third party libraries.

optional-dependencies.tests = [
"pyfakefs",
"pytest",
Expand Down
2 changes: 1 addition & 1 deletion src/blurb/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from ._version import __version__
from ._version import __version__ as __version__
Loading