Skip to content
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

[pull] master from python-semantic-release:master #111

Merged
merged 46 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
adc0c15
build(deps-dev): bump mypy from 1.10.0 to 1.10.1 (#970)
dependabot[bot] Jul 2, 2024
d8a485a
build(deps-dev): bump ruff from 0.4.9 to 0.5.0
dependabot[bot] Jul 2, 2024
77a5e86
chore(deps-dev): bump ruff pre-commit hook from 0.4.9 to 0.5.0
codejedi365 Jul 4, 2024
f49e579
style(version-cmd): re-apply ruff rule ignore string as it was undete…
codejedi365 Jul 4, 2024
a285476
ci(deps): bump mikepenz/action-junit-report in the github-actions group
dependabot[bot] Jun 24, 2024
8b26104
chore: switch to ruff doc formatting & add ignore types (#964)
wyardley Jul 4, 2024
62a0013
build(deps-dev): update `types-requests` from ~=2.31.0 to ~=2.32.0 (#…
dependabot[bot] Jul 4, 2024
ff043f6
chore(conf): set `ignore-without-code` for mypy (#971)
wyardley Jul 4, 2024
2586487
refactor(changelog-cmd): improve readability & logical flow
codejedi365 Jun 22, 2024
bded8de
fix(changelog-cmd): render default changelog when user template direc…
codejedi365 Jun 22, 2024
4b15e4a
refactor(publish-cmd): improve readability & logical flow
codejedi365 Jun 22, 2024
ce643cf
refactor(config): ensure template directory path is resolved
codejedi365 Jun 22, 2024
3eb3dba
fix(config): prevent path traversal manipulation of target changelog …
codejedi365 Jun 22, 2024
e33be16
refactor(cli-ctx): relocate ctx object to parent module
codejedi365 Jun 22, 2024
3e9e74d
refactor(hvcs-remote-base): added `noop` parameter to `create_release()`
codejedi365 Jun 30, 2024
9e01444
refactor(hvcs-bitbucket): added `noop` parameter to `create_release()`
codejedi365 Jun 30, 2024
d22025b
refactor(hvcs-gitea): added `noop` parameter to `create_release()`
codejedi365 Jun 30, 2024
2729b91
refactor(hvcs-github): added `noop` parameter to `create_release()`
codejedi365 Jun 30, 2024
57073f7
refactor(hvcs-gitlab): added `noop` parameter to `create_release()`
codejedi365 Jun 30, 2024
3bbb217
refactor(cli): convert to subcommand dynamic loading
codejedi365 Jun 30, 2024
47090ff
test(cli-*): refactor cli command import references
codejedi365 Jun 30, 2024
f8819f3
test(util): add fancy exit-code assertion method
codejedi365 Jun 30, 2024
efba1ed
test(cli-*): apply improved exit-code validation w/ error msgs
codejedi365 Jun 30, 2024
6d10fec
test(cli-publish): refactor for improved testing
codejedi365 Jun 30, 2024
8d3c91b
test(util): add utility func to generate full mock module paths to fu…
codejedi365 Jun 30, 2024
dea2887
style(test): improve maintainability via fixture references & typing
codejedi365 Jun 30, 2024
f9a038e
refactor(release): add version into release object
codejedi365 Jun 30, 2024
79dbf58
style: improve readability & formatting
codejedi365 Jun 30, 2024
16afbbb
fix(publish-cmd): prevent error when provided tag does not exist locally
codejedi365 Jun 30, 2024
d247101
refactor(changelog): consolidate changelog/release-notes generator code
codejedi365 Jun 30, 2024
991d4e6
refactor(changelog-cmd): simplify and improve implementation
codejedi365 Jun 30, 2024
d1d53fe
refactor(version-cmd): simplify and improve implementation
codejedi365 Jun 30, 2024
cdd6468
refactor(conf): fix console_script definition for cli
codejedi365 Jun 30, 2024
e15bb49
refactor(version-cmd): simplify & improve for maintainability
codejedi365 Jun 30, 2024
a7c17c7
fix(version-cmd): remove usage strings when error occurred
codejedi365 Jun 30, 2024
23ce5de
style: correct linting & formatting
codejedi365 Jun 30, 2024
243f0b1
refactor(runtime-ctx): change `repo` to `repo_dir` for context manage…
codejedi365 May 13, 2024
4df79c5
refactor(version-cmd): simplify command logic with separate git actio…
codejedi365 Jul 4, 2024
8cbce47
test(changelog-cmd): add tests to exercise validity of user template dir
codejedi365 Jul 4, 2024
be4919c
test(changelog): add tests to exercise path traversal attack prevention
codejedi365 Jul 4, 2024
43e35d0
fix(config): prevent path traversal manipulation of target changelog …
codejedi365 Jul 4, 2024
c841eee
test(cli): refactor for better performance & accuracy
codejedi365 Jul 4, 2024
afbb187
fix(publish-cmd): remove usage strings when error occured
codejedi365 Jul 4, 2024
348a51d
fix(changelog-cmd): remove usage strings when error occured
codejedi365 Jul 4, 2024
7342484
style: beautify 348a51db8a837d951966aff3789aa0c93d473829
actions-user Jul 4, 2024
e02a9bd
9.8.4
Jul 4, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
--junit-xml=tests/reports/pytest-results.xml

- name: Report | Upload Test Results
uses: mikepenz/action-junit-report@v4.2.2
uses: mikepenz/action-junit-report@v4.3.1
if: ${{ always() && steps.tests.outcome != 'skipped' }}
with:
report_paths: ./tests/reports/*.xml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
--junit-xml=tests/reports/pytest-results.xml

- name: Report | Upload Test Results
uses: mikepenz/action-junit-report@v4.2.2
uses: mikepenz/action-junit-report@v4.3.1
if: ${{ always() && steps.tests.outcome != 'skipped' }}
with:
report_paths: ./tests/reports/*.xml
Expand Down
9 changes: 1 addition & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ repos:
- id: mixed-line-ending
- id: check-ast

- repo: https://github.com/adamchainz/blacken-docs
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: ["black==23.10.1"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.16.0
hooks:
Expand All @@ -43,7 +37,7 @@ repos:

# Linters and validation
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
rev: v0.5.0
hooks:
- id: ruff
name: ruff (lint)
Expand Down Expand Up @@ -71,7 +65,6 @@ repos:
hooks:
# - id: python-use-type-annotations
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-check-mock-methods
- id: python-no-eval
- id: python-no-log-warn
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# CHANGELOG

## v9.8.4 (2024-07-04)

### Fix

* fix(changelog-cmd): remove usage strings when error occured

Resolves: #810 ([`348a51d`](https://github.com/python-semantic-release/python-semantic-release/commit/348a51db8a837d951966aff3789aa0c93d473829))

* fix(publish-cmd): remove usage strings when error occured

Resolves: #810 ([`afbb187`](https://github.com/python-semantic-release/python-semantic-release/commit/afbb187d6d405fdf6765082e2a1cecdcd7d357df))

* fix(config): prevent path traversal manipulation of target changelog location ([`43e35d0`](https://github.com/python-semantic-release/python-semantic-release/commit/43e35d0972e8a29239d18ed079d1e2013342fcbd))

* fix(version-cmd): remove usage strings when error occurred

Resolves: #810 ([`a7c17c7`](https://github.com/python-semantic-release/python-semantic-release/commit/a7c17c73fd7becb6d0e042e45ff6765605187e2a))

* fix(publish-cmd): prevent error when provided tag does not exist locally ([`16afbbb`](https://github.com/python-semantic-release/python-semantic-release/commit/16afbbb8fbc3a97243e96d7573f4ad2eba09aab9))

* fix(config): prevent path traversal manipulation of target changelog location ([`3eb3dba`](https://github.com/python-semantic-release/python-semantic-release/commit/3eb3dbafec4223ee463b90e927e551639c69426b))

* fix(changelog-cmd): render default changelog when user template directory exist but is empty ([`bded8de`](https://github.com/python-semantic-release/python-semantic-release/commit/bded8deae6c92f6dde9774802d9f3716a5cb5705))

## v9.8.3 (2024-06-18)

### Fix
Expand Down
18 changes: 11 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "python-semantic-release"
version = "9.8.3"
version = "9.8.4"
description = "Automatic Semantic Versioning for Python projects"
requires-python = ">=3.8"
license = { text = "MIT" }
Expand Down Expand Up @@ -37,8 +37,8 @@ dependencies = [
]

[project.scripts]
semantic-release = "semantic_release.cli:main"
psr = "semantic_release.cli:main"
semantic-release = "semantic_release.cli.commands.main:main"
psr = "semantic_release.cli.commands.main:main"

[project.urls]
changelog = "https://github.com/python-semantic-release/python-semantic-release/blob/master/CHANGELOG.md"
Expand Down Expand Up @@ -74,11 +74,11 @@ test = [
dev = [
"pre-commit ~= 3.5",
"tox ~= 4.11",
"ruff == 0.4.9"
"ruff == 0.5.0"
]
mypy = [
"mypy == 1.10.0",
"types-requests ~= 2.31.0"
"mypy == 1.10.1",
"types-requests ~= 2.32.0",
]

[tool.pytest.ini_options]
Expand Down Expand Up @@ -156,6 +156,7 @@ show_error_context = true
pretty = true
error_summary = true
follow_imports = "normal"
enable_error_code = ["ignore-without-code"]
ignore_missing_imports = true # gitpython is very dynamic
disallow_untyped_calls = true
# warn_return_any = true
Expand Down Expand Up @@ -236,6 +237,8 @@ ignore = [
"INP001",
# Errors should end with "Error"
"N818",
# mypy prevents blanket-type-ignore
"PGH003",
# Fixtures that do not return a value need an underscore prefix. The rule
# does not handle generators.
"PT004",
Expand Down Expand Up @@ -287,9 +290,10 @@ external = ["V"]
task-tags = ["NOTE", "TODO", "FIXME", "XXX"]

[tool.ruff.format]
quote-style = "double"
docstring-code-format = true
indent-style = "space"
line-ending = "lf"
quote-style = "double"

[tool.ruff.lint.per-file-ignores]
# Imported but unused
Expand Down
22 changes: 20 additions & 2 deletions semantic_release/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,25 @@
tags_and_versions,
)

__version__ = "9.8.3"
__version__ = "9.8.4"

__all__ = [
"CommitParser",
"ParsedCommit",
"ParseError",
"ParseResult",
"ParseResultType",
"ParserOptions",
"LevelBump",
"SemanticReleaseBaseError",
"CommitParseError",
"InvalidConfiguration",
"InvalidVersion",
"Version",
"VersionTranslator",
"next_version",
"tags_and_versions",
]


def setup_hook(argv: list[str]) -> None:
Expand All @@ -36,6 +54,6 @@ def setup_hook(argv: list[str]) -> None:
if len(argv) > 1 and any(
cmd in argv for cmd in ["version", "publish", "changelog"]
):
from semantic_release.cli import main
from semantic_release.cli.commands.main import main

main()
2 changes: 1 addition & 1 deletion semantic_release/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys

from semantic_release.cli import main
from semantic_release.cli.commands.main import main

if __name__ == "__main__":
main(args=sys.argv[1:])
26 changes: 25 additions & 1 deletion semantic_release/changelog/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,32 @@
if TYPE_CHECKING:
from jinja2 import Environment

from semantic_release.changelog.release_history import ReleaseHistory
from semantic_release.changelog.release_history import Release, ReleaseHistory
from semantic_release.hvcs._base import HvcsBase
from semantic_release.version.version import Version


@dataclass
class ReleaseNotesContext:
repo_name: str
repo_owner: str
hvcs_type: str
version: Version
release: Release
filters: tuple[Callable[..., Any], ...] = ()

def bind_to_environment(self, env: Environment) -> Environment:
env_globals = dict(
filter(lambda k_v: k_v[0] != "filters", self.__dict__.items())
)

for g, v in env_globals.items():
env.globals[g] = v

for f in self.filters:
env.filters[f.__name__] = f

return env


@dataclass
Expand Down
3 changes: 3 additions & 0 deletions semantic_release/changelog/release_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def from_git_history(
committer=committer,
tagged_date=tagged_date,
elements=defaultdict(list),
version=the_version,
)

released.setdefault(the_version, release)
Expand Down Expand Up @@ -165,6 +166,7 @@ def release(
"committer": committer,
"tagged_date": tagged_date,
"elements": self.unreleased,
"version": version,
},
**self.released,
},
Expand All @@ -183,3 +185,4 @@ class Release(TypedDict):
committer: Actor
tagged_date: datetime
elements: dict[str, list[ParseResult]]
version: Version
10 changes: 0 additions & 10 deletions semantic_release/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
from semantic_release.cli.commands.changelog import changelog
from semantic_release.cli.commands.generate_config import generate_config
from semantic_release.cli.commands.main import main
from semantic_release.cli.commands.publish import publish
from semantic_release.cli.commands.version import version

main.add_command(changelog)
main.add_command(generate_config)
main.add_command(version)
main.add_command(publish)
Loading