diff --git a/poetry.lock b/poetry.lock index 9ef88c859..c0ba460f9 100644 --- a/poetry.lock +++ b/poetry.lock @@ -217,7 +217,7 @@ python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" [[package]] name = "platformdirs" -version = "2.4.1" +version = "2.5.0" description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" optional = false @@ -294,7 +294,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" [[package]] name = "tomli" -version = "2.0.0" +version = "2.0.1" description = "A lil' TOML parser" category = "dev" optional = false @@ -302,7 +302,7 @@ python-versions = ">=3.7" [[package]] name = "tomlkit" -version = "0.9.0" +version = "0.9.2" description = "Style preserving TOML library" category = "main" optional = false @@ -535,8 +535,8 @@ pathspec = [ {file = "pathspec-0.9.0.tar.gz", hash = "sha256:e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"}, ] platformdirs = [ - {file = "platformdirs-2.4.1-py3-none-any.whl", hash = "sha256:1d7385c7db91728b83efd0ca99a5afb296cab9d0ed8313a45ed8ba17967ecfca"}, - {file = "platformdirs-2.4.1.tar.gz", hash = "sha256:440633ddfebcc36264232365d7840a970e75e1018d15b4327d11f91909045fda"}, + {file = "platformdirs-2.5.0-py3-none-any.whl", hash = "sha256:30671902352e97b1eafd74ade8e4a694782bd3471685e78c32d0fdfd3aa7e7bb"}, + {file = "platformdirs-2.5.0.tar.gz", hash = "sha256:8ec11dfba28ecc0715eb5fb0147a87b1bf325f349f3da9aab2cd6b50b96b692b"}, ] pylint = [ {file = "pylint-2.12.2-py3-none-any.whl", hash = "sha256:daabda3f7ed9d1c60f52d563b1b854632fd90035bcf01443e234d3dc794e3b74"}, @@ -559,12 +559,12 @@ toml = [ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] tomli = [ - {file = "tomli-2.0.0-py3-none-any.whl", hash = "sha256:b5bde28da1fed24b9bd1d4d2b8cba62300bfb4ec9a6187a957e8ddb9434c5224"}, - {file = "tomli-2.0.0.tar.gz", hash = "sha256:c292c34f58502a1eb2bbb9f5bbc9a5ebc37bee10ffb8c2d6bbdfa8eb13cc14e1"}, + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] tomlkit = [ - {file = "tomlkit-0.9.0-py3-none-any.whl", hash = "sha256:c1b0fc73abd4f1e77c29ea4061ca0f2e11cbfb77342e17df3d3fdd496fc3f899"}, - {file = "tomlkit-0.9.0.tar.gz", hash = "sha256:5a83672c565f78f5fc8f1e44e5f2726446cc6b765113efd21d03e9331747d9ab"}, + {file = "tomlkit-0.9.2-py3-none-any.whl", hash = "sha256:daf4f9c5f2fbf6b861d6adfc51940b98dee36c13e1d88749a6dc9fb280fff304"}, + {file = "tomlkit-0.9.2.tar.gz", hash = "sha256:ebd982d61446af95a1e082b103e250cb9e6d152eae2581d4a07d31a70b34ab0f"}, ] typed-ast = [ {file = "typed_ast-1.5.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:183b183b7771a508395d2cbffd6db67d6ad52958a5fdc99f450d954003900266"}, diff --git a/pontos/changelog/conventional_commits.py b/pontos/changelog/conventional_commits.py index 164d8722d..3f4227080 100644 --- a/pontos/changelog/conventional_commits.py +++ b/pontos/changelog/conventional_commits.py @@ -69,9 +69,14 @@ def create_changelog_file(self) -> Union[Path, None]: def get_git_log(self) -> Union[List[str], None]: # https://stackoverflow.com/a/12083016/6725620 # uses only latest tag for this branch - proc = self.shell_cmd_runner( - 'git log "$(git describe --tags --abbrev=0)..HEAD" --oneline' + proc: subprocess.CompletedProcess = self.shell_cmd_runner( + "git describe --tags --abbrev=0" ) + if proc.stdout and proc.stdout != '': + cmd: str = f'git log "{proc.stdout.strip()}..HEAD" --oneline' + else: + cmd: str = 'git log HEAD --oneline' + proc = self.shell_cmd_runner(cmd) if proc.stdout and proc.stdout != '': return proc.stdout.strip().split('\n') return None diff --git a/tests/changelog/test_conventional_commits.py b/tests/changelog/test_conventional_commits.py index 0ae38fd26..0f81bffb1 100644 --- a/tests/changelog/test_conventional_commits.py +++ b/tests/changelog/test_conventional_commits.py @@ -45,6 +45,7 @@ def test_changelog_builder(self): config_toml = own_path / 'changelog.toml' release_version = '0.0.2' output = f'v{release_version}.md' + git_tag = "v0.0.1" git_log = ( '1234567 Add: foo bar\n' '8abcdef Add: bar baz\n' @@ -61,6 +62,8 @@ def test_changelog_builder(self): def runner(cmd): called.append(cmd) + if cmd == "git describe --tags --abbrev=0": + return StdOutput(git_tag) return StdOutput(git_log) cargs = Namespace( @@ -111,7 +114,12 @@ def runner(cmd): ) self.assertIn( - 'git log "$(git describe --tags --abbrev=0)..HEAD" --oneline', + 'git describe --tags --abbrev=0', + called, + ) + + self.assertIn( + 'git log "v0.0.1..HEAD" --oneline', called, )