Compare commits
10 Commits
52543a0e89
...
9f37df4520
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f37df4520 | ||
|
|
22a1f90241 | ||
|
|
40c751bc45 | ||
|
|
7b62bc25d7 | ||
|
|
e033ec7edb | ||
|
|
44e2f80cb8 | ||
|
|
8d065ef878 | ||
|
|
86e9920574 | ||
|
|
4e3130b5b0 | ||
|
|
162b835413 |
150
Improved-error-checking-when-parsing-a-Blurb.patch
Normal file
150
Improved-error-checking-when-parsing-a-Blurb.patch
Normal file
@ -0,0 +1,150 @@
|
||||
From d4b7d536b2c0228ce09d7c8271f9aeb0889b6927 Mon Sep 17 00:00:00 2001
|
||||
From: larryhastings <larry@hastings.org>
|
||||
Date: Sun, 23 Jul 2023 06:36:51 -0700
|
||||
Subject: [PATCH] Improved error checking when parsing a Blurb. (#507)
|
||||
|
||||
We now:
|
||||
* Check the entries in metadata in order, so we complain about
|
||||
the *first* one that has an error, which is a more familiar
|
||||
user experience.
|
||||
* Have checks for:
|
||||
* Invalid issue number
|
||||
* Invalid section
|
||||
* Empty section
|
||||
* Completely missing section
|
||||
|
||||
(There is no test for "missing issue number", because it's legal
|
||||
to have a Blurb with no issue number. "no changes" blurbs don't
|
||||
have an issue number. But we do now reliably test that, *if* the
|
||||
issue number is specified, it *is* correctly formatted.)
|
||||
---
|
||||
blurb.py | 54 ++++++++++++++++++++------------
|
||||
tests/fail/invalid-gh-number.rst | 4 +++
|
||||
tests/fail/invalid-section.rst | 4 +++
|
||||
tests/fail/no-gh-number.rst | 4 +++
|
||||
tests/fail/no-section.rst | 3 ++
|
||||
5 files changed, 49 insertions(+), 20 deletions(-)
|
||||
create mode 100644 tests/fail/invalid-gh-number.rst
|
||||
create mode 100644 tests/fail/invalid-section.rst
|
||||
create mode 100644 tests/fail/no-gh-number.rst
|
||||
create mode 100644 tests/fail/no-section.rst
|
||||
|
||||
diff --git a/blurb.py b/blurb.py
|
||||
index 51f1087..7557c23 100755
|
||||
--- a/blurb.py
|
||||
+++ b/blurb.py
|
||||
@@ -472,27 +472,34 @@ class Blurbs(list):
|
||||
throw("Blurb 'body' can't start with " + repr(naughty_prefix) + "!")
|
||||
|
||||
no_changes = metadata.get('no changes')
|
||||
- section = metadata.get('section')
|
||||
-
|
||||
- if not no_changes:
|
||||
- if not section:
|
||||
- throw("No 'section' specified. You must provide one!")
|
||||
- elif section not in sections:
|
||||
- throw("Invalid 'section'! You must use one of the predefined sections.")
|
||||
-
|
||||
- issue_number = None
|
||||
-
|
||||
- if metadata.get("gh-issue") is not None:
|
||||
- try:
|
||||
- issue_number = int(metadata.get('gh-issue'))
|
||||
- except (TypeError, ValueError):
|
||||
- throw("Invalid GitHub issue number! (" + repr(issue_number) + ")")
|
||||
- elif metadata.get("bpo") is not None:
|
||||
- try:
|
||||
- issue_number = int(metadata.get('bpo'))
|
||||
- except (TypeError, ValueError):
|
||||
- throw("Invalid bpo issue number! (" + repr(issue_number) + ")")
|
||||
|
||||
+ issue_keys = {
|
||||
+ 'gh-issue': 'GitHub',
|
||||
+ 'bpo': 'bpo',
|
||||
+ }
|
||||
+ for key, value in metadata.items():
|
||||
+ # Iterate over metadata items in order.
|
||||
+ # We parsed the blurb file line by line,
|
||||
+ # so we'll insert metadata keys in the
|
||||
+ # order we see them. So if we issue the
|
||||
+ # errors in the order we see the keys,
|
||||
+ # we'll complain about the *first* error
|
||||
+ # we see in the blurb file, which is a
|
||||
+ # better user experience.
|
||||
+ if key in issue_keys:
|
||||
+ try:
|
||||
+ int(value)
|
||||
+ except (TypeError, ValueError):
|
||||
+ throw(f"Invalid {issue_keys[key]} issue number! ({value!r})")
|
||||
+
|
||||
+ if key == "section":
|
||||
+ if no_changes:
|
||||
+ continue
|
||||
+ if value not in sections:
|
||||
+ throw(f"Invalid section {value!r}! You must use one of the predefined sections.")
|
||||
+
|
||||
+ if not 'section' in metadata:
|
||||
+ throw("No 'section' specified. You must provide one!")
|
||||
|
||||
self.append((metadata, text))
|
||||
metadata = {}
|
||||
@@ -854,6 +861,13 @@ Run unit tests. Only works inside source repo, not when installed.
|
||||
# unittest.main doesn't work because this isn't a module
|
||||
# so we'll do it ourselves
|
||||
|
||||
+ while not (os.path.isdir(".git") and os.path.isdir("blurb")):
|
||||
+ old_dir = os.getcwd()
|
||||
+ os.chdir("..")
|
||||
+ if old_dir == os.getcwd():
|
||||
+ # we reached the root and never found it!
|
||||
+ sys.exit("Error: Couldn't find the root of your blurb repo!")
|
||||
+
|
||||
print("-" * 79)
|
||||
|
||||
for clsname, cls in sorted(globals().items()):
|
||||
diff --git a/tests/fail/invalid-gh-number.rst b/tests/fail/invalid-gh-number.rst
|
||||
new file mode 100644
|
||||
index 0000000..6d60917
|
||||
--- /dev/null
|
||||
+++ b/tests/fail/invalid-gh-number.rst
|
||||
@@ -0,0 +1,4 @@
|
||||
+.. gh-issue: abcde
|
||||
+.. section: Library
|
||||
+
|
||||
+Things, stuff.
|
||||
\ No newline at end of file
|
||||
diff --git a/tests/fail/invalid-section.rst b/tests/fail/invalid-section.rst
|
||||
new file mode 100644
|
||||
index 0000000..1c0af55
|
||||
--- /dev/null
|
||||
+++ b/tests/fail/invalid-section.rst
|
||||
@@ -0,0 +1,4 @@
|
||||
+.. gh-issue: 8675309
|
||||
+.. section: Funky Kong
|
||||
+
|
||||
+This is an invalid blurb. Shockingly, "Funky Kong" is not a valid section name.
|
||||
\ No newline at end of file
|
||||
diff --git a/tests/fail/no-gh-number.rst b/tests/fail/no-gh-number.rst
|
||||
new file mode 100644
|
||||
index 0000000..480fcbf
|
||||
--- /dev/null
|
||||
+++ b/tests/fail/no-gh-number.rst
|
||||
@@ -0,0 +1,4 @@
|
||||
+.. gh-issue:
|
||||
+.. section: Library
|
||||
+
|
||||
+Things, stuff.
|
||||
\ No newline at end of file
|
||||
diff --git a/tests/fail/no-section.rst b/tests/fail/no-section.rst
|
||||
new file mode 100644
|
||||
index 0000000..f6e06aa
|
||||
--- /dev/null
|
||||
+++ b/tests/fail/no-section.rst
|
||||
@@ -0,0 +1,3 @@
|
||||
+.. gh-issue: 8675309
|
||||
+
|
||||
+This is an invalid blurb. It doesn't have a "section".
|
||||
\ No newline at end of file
|
||||
--
|
||||
2.27.0
|
||||
|
||||
Binary file not shown.
BIN
blurb-1.1.0.tar.gz
Normal file
BIN
blurb-1.1.0.tar.gz
Normal file
Binary file not shown.
@ -1,72 +1,62 @@
|
||||
%global pypi_name blurb
|
||||
%global _empty_manifest_terminate_build 0
|
||||
Name: python-blurb
|
||||
Version: 1.1.0
|
||||
Release: 5
|
||||
Summary: Command-line tool to manage CPython Misc/NEWS.d entries.
|
||||
License: BSD-3-Clause
|
||||
URL: https://github.com/python/blurb
|
||||
Source0: https://files.pythonhosted.org/packages/71/34/676f8c4a16ac69cc5a1a59d871f6c34d019fb5f36df3a44d4e3e5f4b7362/blurb-1.1.0.tar.gz
|
||||
Patch0: Improved-error-checking-when-parsing-a-Blurb.patch
|
||||
BuildArch: noarch
|
||||
|
||||
Name: python-%{pypi_name}
|
||||
Version: 1.0.8
|
||||
Release: 1
|
||||
Summary: Command-line tool to manage CPython Misc/NEWS.d entries
|
||||
|
||||
License: BSD
|
||||
URL: https://github.com/python/core-workflow/tree/master/%{pypi_name}
|
||||
Source0: https://files.pythonhosted.org/packages/00/09/362bcf19fa247d66f7eb50c620265b2c2b037efaab64f6cb3865034e21f0/%{pypi_name}-%{version}.tar.gz
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
blurb is a tool designed to rid CPython core development of the scourge of Misc/NEWS conflicts.
|
||||
|
||||
|
||||
%package -n python3-%{pypi_name}
|
||||
Summary: Command-line tool to manage CPython Misc/NEWS.d entries.
|
||||
Provides: python-%{pypi_name}
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools
|
||||
%description -n python3-%{pypi_name}
|
||||
%package -n python3-blurb
|
||||
Summary: Command-line tool to manage CPython Misc/NEWS.d entries.
|
||||
Provides: python-blurb
|
||||
Obsoletes: python-blurb-help <= 1.1.0
|
||||
BuildRequires: python3-devel
|
||||
BuildRequires: python3-setuptools python3-pip python3-wheel python3-flit
|
||||
%description -n python3-blurb
|
||||
blurb is a tool designed to rid CPython core development of the scourge of Misc/NEWS conflicts.
|
||||
|
||||
|
||||
%prep
|
||||
%autosetup -n %{pypi_name}-%{version}
|
||||
|
||||
%autosetup -n blurb-%{version} -p1
|
||||
|
||||
%build
|
||||
%py3_build
|
||||
|
||||
%pyproject_build
|
||||
|
||||
%install
|
||||
%py3_install
|
||||
install -d -m755 %{buildroot}/%{_pkgdocdir}
|
||||
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
|
||||
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
|
||||
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
|
||||
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
|
||||
pushd %{buildroot}
|
||||
if [ -d usr/lib ]; then
|
||||
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
if [ -d usr/lib64 ]; then
|
||||
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
if [ -d usr/bin ]; then
|
||||
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
if [ -d usr/sbin ]; then
|
||||
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
|
||||
fi
|
||||
touch doclist.lst
|
||||
if [ -d usr/share/man ]; then
|
||||
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
|
||||
fi
|
||||
popd
|
||||
mv %{buildroot}/filelist.lst .
|
||||
mv %{buildroot}/doclist.lst .
|
||||
%pyproject_install blurb==%{version}
|
||||
|
||||
%check
|
||||
PYTHONPATH=%{buildroot}%{python3_sitelib} %{buildroot}%{_bindir}/blurb --help
|
||||
|
||||
%files -n python3-%{pypi_name} -f filelist.lst
|
||||
%doc README.rst
|
||||
%files -n python3-blurb
|
||||
%{python3_sitelib}/*
|
||||
%license LICENSE.txt
|
||||
%dir %{python3_sitelib}/*
|
||||
|
||||
%doc README.rst
|
||||
%{_bindir}/blurb
|
||||
|
||||
%changelog
|
||||
* Fri May 10 2024 lilu <lilu@kylinos.cn> - 1.1.0-5
|
||||
- Improved error checking when parsing a Blurb
|
||||
|
||||
* Thu May 9 2024 tenglei <tenglei@kylinos.cn> - 1.1.0-4
|
||||
- url have changed on github, sync change
|
||||
|
||||
* Thu Apr 27 2023 wangkai <13474090681@163.com> - 1.1.0-3
|
||||
- Compling package with pyproject
|
||||
- Obsoletes subpackage python-blurb-help
|
||||
- Add check for blurb command
|
||||
|
||||
* Mon Feb 27 2023 caodongxia <caodongxia@h-partners.com> - 1.1.0-2
|
||||
- Adaptation to setup.py
|
||||
|
||||
* Fri Oct 14 2022 guozhengxin <guozhengxin@kylinos.cn> - 1.1.0-1
|
||||
- Upgrade package to version 1.1.0
|
||||
|
||||
* Mon Jul 12 2021 ice-kylin <wminid@yeah.net> - 1.0.8-1
|
||||
- Initial package
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user