diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 73f482297..004b284d3 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -7,6 +7,6 @@ Fixes #(issue) # Checklist (delete if not relevant): - [ ] I have added tests that prove my fix is effective or that my feature works -- [ ] I have updated CHANGELOG.md +- [ ] I have added a changelog fragment to `changelog.d/` (see `changelog.d/README.md`) - [ ] I have made corresponding changes to user documentation for new features - [ ] I have made corresponding changes to library documentation for API changes diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bb036f7f..8238aa4bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,3 @@ -# **Upcoming release** - -- #223 Add regression tests for restructuring and patchedast with `elif(` written without a space (@mcepl) - - # Release 1.16.0 - #859 Fix `find_definition`/Rename not resolving `async def` methods called via `self` (@gadievron) diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..74b3841f4 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +# Maintenance tasks for rope. +# +# Changelog entries live as individual fragments in changelog.d/ +# (one file per PR, see changelog.d/README.md) and are only merged +# into CHANGELOG.md at release time, so that pull requests do not +# keep conflicting on the top of CHANGELOG.md. The real work is done +# by bin/news; this Makefile is kept portable (GNU make, BSD make). + +NEWS = ./bin/news + +.PHONY: help news changelog-preview changelog docs release + +help: + @echo "make news N= write a changelog fragment in \$$EDITOR" + @echo " (or bin/news )" + @echo "make changelog-preview show the pending changelog entries" + @echo "make changelog fold fragments into CHANGELOG.md" + @echo "make docs build the HTML documentation" + @echo "make release changelog + docs" + +news: + @$(NEWS) add "$$N" "$$TEXT" + +changelog-preview: + @$(NEWS) preview + +changelog: + @$(NEWS) collect + +docs: + cd docs && $(MAKE) html + +release: changelog docs diff --git a/bin/news b/bin/news new file mode 100755 index 000000000..217762c08 --- /dev/null +++ b/bin/news @@ -0,0 +1,132 @@ +#!/bin/sh +# Manage changelog fragments in changelog.d/ (see changelog.d/README.md). +# +# bin/news [add] [text] create changelog.d/.md, +# in $VISUAL/$EDITOR unless text given +# bin/news preview show the pending release section +# bin/news collect fold the fragments into CHANGELOG.md +# +# Deliberately plain POSIX sh, so it works the same on Linux, the BSDs +# and macOS. + +set -eu + +cd "$(dirname "$0")/.." +NEWS_DIR=changelog.d +CHANGELOG=CHANGELOG.md + +die() { + printf '%s\n' "$*" >&2 + exit 1 +} + +usage() { + sed -n '4,7s/^# \{0,1\}//p' "$0" >&2 + exit 2 +} + +version() { + v=$(sed -n "s/^version *= *['\"]\([^'\"]*\)['\"].*/\1/p" pyproject.toml) + [ -n "$v" ] || die "Cannot find version in pyproject.toml" + printf '%s\n' "$v" +} + +# Fragment file names, sorted by issue number. +fragments() { + for f in "$NEWS_DIR"/[0-9]*.md; do + [ -e "$f" ] && basename "$f" + done | sort -n | sed "s|^|$NEWS_DIR/|" +} + +template() { + cat <"$tmp" + else + template "$n" >"$tmp" + # unquoted on purpose: allow e.g. EDITOR='code --wait' + ${VISUAL:-${EDITOR:-vi}} "$tmp" + fi + + # drop comments and leading (and, via $(), trailing) blank lines + entry=$(grep -v -E '^#( |$)' "$tmp" | sed -e '/./,$!d') + rest=$(printf '%s' "$entry" | sed -e "s/^- #$n//" | tr -d '[:space:]') + [ -n "$rest" ] || die "Empty entry, nothing written." + + printf '%s\n' "$entry" >"$f" + printf 'Created %s:\n' "$f" + cat "$f" +} + +cmd_preview() { + files=$(fragments) + [ -n "$files" ] || die "No fragments in $NEWS_DIR/" + printf '# Release %s\n\n' "$(version)" + # shellcheck disable=SC2086 # file names are digits and dashes only + cat $files +} + +cmd_collect() { + v=$(version) + files=$(fragments) + [ -n "$files" ] || die "No fragments in $NEWS_DIR/" + ! grep -q -x -F "# Release $v" "$CHANGELOG" || + die "$CHANGELOG already has 'Release $v';" \ + "bump version in pyproject.toml first" + + tmp=$(mktemp "${TMPDIR:-/tmp}/changelog.XXXXXX") + trap 'rm -f "$tmp"' EXIT + { + cmd_preview + echo + cat "$CHANGELOG" + } >"$tmp" + cat "$tmp" >"$CHANGELOG" + # shellcheck disable=SC2086 + rm -f $files + git add -A "$NEWS_DIR" "$CHANGELOG" + echo "$CHANGELOG updated for $v; review and commit." +} + +[ $# -ge 1 ] || usage +case $1 in + add) shift; cmd_add "$@" ;; + preview) cmd_preview ;; + collect) cmd_collect ;; + -h | --help | help) usage ;; + [0-9]*) cmd_add "$@" ;; + *) usage ;; +esac diff --git a/changelog.d/223.md b/changelog.d/223.md new file mode 100644 index 000000000..0d98c1bac --- /dev/null +++ b/changelog.d/223.md @@ -0,0 +1 @@ +- #223 Add regression tests for restructuring and patchedast with `elif(` written without a space (@mcepl) diff --git a/changelog.d/985.md b/changelog.d/985.md new file mode 100644 index 000000000..3453ea80f --- /dev/null +++ b/changelog.d/985.md @@ -0,0 +1 @@ +- #985 create new system for combining CHANGELOG.md from individual snippets for each PR (@mcepl) diff --git a/changelog.d/987.md b/changelog.d/987.md new file mode 100644 index 000000000..e48c5a2a3 --- /dev/null +++ b/changelog.d/987.md @@ -0,0 +1,4 @@ +- #987 Stop emitting a spurious `DeprecationWarning: Delete once + deprecated functions are gone` on every `Project()` construction; + the marker had been mistakenly left on the live, private + `Project._init_source_folders` since 2014. (@mcepl) diff --git a/changelog.d/README.md b/changelog.d/README.md new file mode 100644 index 000000000..c958a198b --- /dev/null +++ b/changelog.d/README.md @@ -0,0 +1,51 @@ +# Changelog fragments + +Instead of editing `CHANGELOG.md` directly (which makes nearly +every pull request conflict with every other one), each pull +request adds a small file to this directory. The fragments are +merged into `CHANGELOG.md` by `make changelog` (part of +`make release`) when a new version is released. + +## How to add an entry + +Create a file named after the issue or pull request number, e.g. +`changelog.d/1234.md`. If you need more than one fragment for the +same number, add a suffix: `1234-docs.md`. The file name **must** +start with a digit and end in `.md`; other files (like this one) +are ignored. + +The easiest way is to run + +```sh +bin/news 1234 # or: make news N=1234 +``` + +which opens `$VISUAL`/`$EDITOR` (falling back to `vi`) with a +template and saves the result as `changelog.d/1234.md`. Leaving +the entry empty aborts without creating anything. + +The content is one or more Markdown list items, in the same style +as the existing `CHANGELOG.md`. Please don't limit yourself to a +terse one-liner: explain what changed, why, and what users of +rope may notice. Wrap long lines and indent continuation lines by +two spaces: + +```markdown +- #1234 Fix renaming of keyword arguments when inlining a method + whose body conflicts with names in the host scope; previously + rope produced `__0__from_lang=` in the result. (@yourname) +``` + +Several related issues may be listed together, e.g. +`- #826, #940 Keep star imports …`. + +For scripts, `bin/news 1234 'Short description (@you)'` (or +`make news N=1234 TEXT='...'`) writes the fragment without +starting an editor. + +Use `bin/news preview` (or `make changelog-preview`) to see what +the next release section will look like. + +`bin/news` is a plain POSIX shell script and the `Makefile` is +portable, so this works with both GNU and BSD make, on Linux, the +BSDs and macOS. diff --git a/docs/Makefile b/docs/Makefile index d4bb2cbb9..b44be6e48 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -12,7 +12,12 @@ BUILDDIR = _build help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -.PHONY: help Makefile +.PHONY: help html Makefile + +# Explicit rule, so that `make html` (used by the top-level +# Makefile) works with BSD make too, which lacks pattern rules. +html: + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). diff --git a/docs/contributing.rst b/docs/contributing.rst index 796699986..ead26066c 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -112,6 +112,21 @@ Follow the instructions on GitHub_ on how to setup Git and fork the `python-rope/rope`_ repository. Once your changes are ready, send a `pull request`_ for review. +Please do not edit ``CHANGELOG.md`` directly. Instead, add a small +changelog fragment named after the issue or pull request number to the +``changelog.d/`` directory. Running ``bin/news 1234`` (or +``make news N=1234``) opens your ``$EDITOR`` with a template and +creates ``changelog.d/1234.md``, e.g.:: + + - #1234 Fix renaming of keyword arguments when inlining a method + whose body conflicts with names in the host scope. (@yourname) + +Longer entries explaining what changed and why are welcome. + +The fragments are collected into ``CHANGELOG.md`` at release time, which +avoids merge conflicts between pull requests. See +``changelog.d/README.md`` for details. + Programming Style ----------------- diff --git a/docs/release-process.rst b/docs/release-process.rst index 87c356864..46da53eed 100644 --- a/docs/release-process.rst +++ b/docs/release-process.rst @@ -11,10 +11,12 @@ Release ------- 1. Ensure tickets assigned to Milestones are up to date -2. Update ``CHANGELOG.md`` -3. Close milestone -4. Increment version number in ``pyproject.toml`` -5. `git commit && git push` +2. Close milestone +3. Increment version number in ``pyproject.toml`` +4. Run ``make release``: it folds the fragments from ``changelog.d/`` + into ``CHANGELOG.md`` (``git rm``-ing the fragments) and builds the + documentation; ``make changelog-preview`` shows the result in advance +5. Review ``CHANGELOG.md``, then ``git commit -a && git push`` 6. Tag the release with the tag annotation containing the release information, ``python bin/tag-release.py`` 7. Create Github Release diff --git a/rope/base/project.py b/rope/base/project.py index c7f6a2f8e..880fc6780 100644 --- a/rope/base/project.py +++ b/rope/base/project.py @@ -230,7 +230,6 @@ def __repr__(self): self.address, ) - @utils.deprecated("Delete once deprecated functions are gone") def _init_source_folders(self): for path in self.prefs.get("source_folders", []): folder = self.get_resource(path)