From e5cbb66169e17206bf12e16d1cb78934ae350676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20B=C3=A4r?= Date: Wed, 18 Dec 2024 12:37:01 +0100 Subject: [PATCH] chore: address PR comments --- git-cliff-release/action.yaml | 10 +++++----- git-cliff-release/cliff.toml | 8 ++++---- git-cliff-release/enhance_context.py | 8 +++++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/git-cliff-release/action.yaml b/git-cliff-release/action.yaml index 9681f32..b60a89e 100644 --- a/git-cliff-release/action.yaml +++ b/git-cliff-release/action.yaml @@ -33,11 +33,11 @@ inputs: required: false type: string default: ${{ github.token }} - no-github: - description: If set to true, the action will not insert links to GitHub issues and PRs in the release notes and changelog. + add-github-links: + description: If set to false, the action will not insert links to GitHub issues and PRs in the release notes and changelog. required: false type: boolean - default: false + default: true outputs: is_prerelease: description: For convenience - was the action triggered with release_type = "prerelease"? @@ -107,7 +107,7 @@ runs: set -x enhance_context_args=() - if [[ ${{ inputs.no-github }} = true ]]; then + if [[ ${{ inputs.add-github-links }} = false ]]; then enhance_context_args+=(--no-github) fi @@ -146,7 +146,7 @@ runs: print_changelog_args+=(--output "$out_file") fi - if [[ ${{ inputs.no-github }} = true ]]; then + if [[ ${{ inputs.add-github-links }} = false ]]; then enhance_context_args+=(--no-github) fi diff --git a/git-cliff-release/cliff.toml b/git-cliff-release/cliff.toml index 79997e8..b0b38a9 100644 --- a/git-cliff-release/cliff.toml +++ b/git-cliff-release/cliff.toml @@ -36,10 +36,10 @@ body = """ {{ commit.message | escape | upper_first }}\ {% endif %}\ {% if commit.extra.commit_link %} ([{{ commit.id | truncate(length = 7, end = "") }}]({{ commit.extra.commit_link }})){% endif %}\ - {% if commit.remote.username and extra.is_release_notes %}\ - {{" "}}by @{{ commit.remote.username }}\ - {% elif not extra.no_github and commit.remote.username %}\ - {{" "}}by [@{{ commit.remote.username }}](https://github.com/{{ commit.remote.username }})\ + {% if commit.extra.username and extra.is_release_notes %}\ + {{" "}}by @{{ commit.extra.username }}\ + {% elif commit.extra.username %}\ + {{" "}}by [@{{ commit.extra.username }}](https://github.com/{{ commit.extra.username }})\ {% if commit.extra.closed_issue_links %}\ , closes {{ commit.extra.closed_issue_links | join(sep = ", ") }}\ {% endif %}\ diff --git a/git-cliff-release/enhance_context.py b/git-cliff-release/enhance_context.py index d81d973..0d7d35c 100644 --- a/git-cliff-release/enhance_context.py +++ b/git-cliff-release/enhance_context.py @@ -44,11 +44,17 @@ def enhance_release( def enhance_commit(commit: dict[str, Any], pr_issues: dict[int, list[int]]) -> None: - pr_number = commit.get("remote", {}).get("pr_number") + commit_remote = commit.get("remote", {}) + + pr_number = commit_remote.get("pr_number") + username = commit_remote.get("username") commit["extra"] = commit["extra"] or {} commit["extra"]["commit_link"] = f"{repo_url}/commit/{commit['id']}" + if username: + commit["extra"]["username"] = username + if pr_number: commit["extra"]["closed_issues"] = pr_issues.get(pr_number, [])