Skip to content

Commit

Permalink
Merge pull request #30 from brainelectronics/bugfix/remove-print-in-d…
Browse files Browse the repository at this point in the history
…etached-HEAD

remove print from detached HEAD
  • Loading branch information
brainelectronics authored Oct 12, 2024
2 parents 3369d04 + ad27898 commit 1d39e73
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
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

0 comments on commit 1d39e73

Please sign in to comment.