Skip to content

Commit

Permalink
Fix: Let pontos-release -CC run when no initial tag is in the rep…
Browse files Browse the repository at this point in the history
…ository. [#276]

Fix: Let pontos run when no initial `tag` is in the repository.
  • Loading branch information
y0urself authored Feb 10, 2022
2 parents ef5f644 + 9ff8919 commit 54c1111
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions pontos/changelog/conventional_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion tests/changelog/test_conventional_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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(
Expand Down Expand Up @@ -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,
)

Expand Down

0 comments on commit 54c1111

Please sign in to comment.