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

Fix: Let pontos run when no initial tag is in the repository. #276

Merged
merged 3 commits into from
Feb 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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