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

remove print from detached HEAD #30

Merged
merged 2 commits into from
Oct 12, 2024
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
19 changes: 13 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,27 @@ jobs:
changelog changelog.md \
--snippets=.snippets \
--dry-run > latest-entry.json
jq -r ".content" latest-entry.json > latest_description.txt
sed -i '/^$/d' latest_description.txt
echo "CHANGELOG_JSON=$(jq -c . < latest-entry.json)" >> $GITHUB_ENV
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
echo "latest_version=$(jq -r '.version' latest-entry.json)" >> $GITHUB_ENV
- name: Update changelog with snippets
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets \
--in-place \
--no-internal

poetry run changelog2version \
--changelog_file changelog.md \
--output changelog.json \
--print \
--debug

jq -r ".info.description" changelog.json > latest_description.txt
sed -i '/^$/d' latest_description.txt
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
echo "latest_version=$(jq -r '.info.version' changelog.json)" >> $GITHUB_ENV
- name: Build package
run: |
poetry run changelog2version \
Expand Down
19 changes: 13 additions & 6 deletions .github/workflows/test-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,27 @@ jobs:
changelog changelog.md \
--snippets=.snippets \
--dry-run > latest-entry.json
jq -r ".content" latest-entry.json > latest_description.txt
sed -i '/^$/d' latest_description.txt
echo "CHANGELOG_JSON=$(jq -c . < latest-entry.json)" >> $GITHUB_ENV
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
echo "latest_version=$(jq -r '.version' latest-entry.json)" >> $GITHUB_ENV
- name: Update changelog with snippets
run: |
poetry run changelog-generator \
changelog changelog.md \
--snippets=.snippets \
--in-place \
--no-internal

poetry run changelog2version \
--changelog_file changelog.md \
--output changelog.json \
--print \
--debug

jq -r ".info.description" changelog.json > latest_description.txt
sed -i '/^$/d' latest_description.txt
echo 'LATEST_DESCRIPTION<<"EOT"' >> $GITHUB_OUTPUT
cat latest_description.txt >> $GITHUB_OUTPUT
echo '"EOT"' >> $GITHUB_OUTPUT
echo "latest_version=$(jq -r '.info.version' changelog.json)" >> $GITHUB_ENV
- name: Build package
run: |
poetry run changelog2version \
Expand Down
8 changes: 8 additions & 0 deletions .snippets/29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Remove print in branch property of HistoryWalker
<!--
type: bugfix
scope: all
affected: all
-->

Using the `branch` property of `HistoryWalker` in `collector.py` would print `HEAD is detached: ...` in case the HEAD is detached during a pull request build. This could lead to errors while creating a changelog with `--dry-run` and passing the output to a supposed JSON file, being finally unable to parse it as with that detached HEAD output it's not a JSON anymore.
2 changes: 1 addition & 1 deletion snippets2changelog/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def branch_name(self) -> str:
try:
return str(self._repo.active_branch)
except Exception as e:
# print(f"HEAD is detached: {e}")
# HEAD is detached
return str(self._repo.head.commit.hexsha)

@property
Expand Down
Loading