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

feat: add includeLinksToGithub property #58

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ jobs:
| `useGitmojis` | Should type headers be prepended with their related gitmoji | :x: | `true` |
| `includeInvalidCommits` | Whether to include commits that don't respect the Conventional Commits format | :x: | `false` |
| `reverseOrder` | List commits in reverse order (from newer to older) instead of the default (older to newer). | :x: | `false` |
| `includeLinksToGithub` | Include links to the GitHub issues and PRs (set to false to not add links) | :x: | `true` |

## Outputs

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ inputs:
description: List commits in reverse order (from newer to older) instead of the default (older to newer).
required: false
default: 'false'
includeLinksToGithub:
description: Include links to the GitHub issues and PRs (set to false to not add links)
required: false
default: 'true'
outputs:
changes:
description: Generated changelog
Expand Down
21 changes: 13 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27984,6 +27984,7 @@ async function main () {
const useGitmojis = core.getBooleanInput('useGitmojis')
const includeInvalidCommits = core.getBooleanInput('includeInvalidCommits')
const reverseOrder = core.getBooleanInput('reverseOrder')
const includeLinksToGithub = core.getBooleanInput('includeLinksToGithub')
const gh = github.getOctokit(token)
const owner = github.context.repo.owner
const repo = github.context.repo.repo
Expand Down Expand Up @@ -28155,8 +28156,9 @@ async function main () {
owner,
repo
})
changesFile.push(`- due to [\`${breakChange.sha.substring(0, 7)}\`](${breakChange.url}) - ${subjectFile.output}:\n\n${body}\n`)
changesVar.push(`- due to [\`${breakChange.sha.substring(0, 7)}\`](${breakChange.url}) - ${subjectVar.output}:\n\n${body}\n`)
const linkToBreakingChange = includeLinksToGithub ? `- [\`${breakChange.sha.substring(0, 7)}\`](${breakChange.url}) - ` : ''
changesFile.push(`- due to ${linkToBreakingChange}${subjectFile.output}:\n\n${body}\n`)
changesVar.push(`- due to ${linkToBreakingChange}${subjectVar.output}:\n\n${body}\n`)
}
idx++
}
Expand Down Expand Up @@ -28212,8 +28214,9 @@ async function main () {
owner,
repo
})
changesFile.push(`- [\`${commit.sha.substring(0, 7)}\`](${commit.url}) - ${scope}${subjectFile.output}`)
changesVar.push(`- [\`${commit.sha.substring(0, 7)}\`](${commit.url}) - ${scope}${subjectVar.output}`)
const linkToCommit = includeLinksToGithub ? `- [\`${commit.sha.substring(0, 7)}\`](${commit.url})` : ''
changesFile.push(`${linkToCommit} - ${scope}${subjectFile.output}`)
changesVar.push(`${linkToCommit} - ${scope}${subjectVar.output}`)

if (includeRefIssues && subjectVar.prs.length > 0) {
for (const prId of subjectVar.prs) {
Expand Down Expand Up @@ -28245,11 +28248,12 @@ async function main () {
const relIssues = _.get(issuesRaw, 'repository.pullRequest.closingIssuesReferences.nodes')
for (const relIssue of relIssues) {
const authorLogin = _.get(relIssue, 'author.login')
const linkToRelIssue = includeLinksToGithub ? `[#${relIssue.number}](${relIssue.url})` : `#${relIssue.number}`
if (authorLogin) {
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue [#${relIssue.number}](${relIssue.url}) opened by [@${authorLogin}](${relIssue.author.url})*`)
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue ${linkToRelIssue} opened by [@${authorLogin}](${relIssue.author.url})*`)
changesVar.push(` - :arrow_lower_right: *${relIssuePrefix} issue #${relIssue.number} opened by @${authorLogin}*`)
} else {
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue [#${relIssue.number}](${relIssue.url})*`)
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue ${linkToRelIssue}*`)
changesVar.push(` - :arrow_lower_right: *${relIssuePrefix} issue #${relIssue.number}*`)
}
}
Expand Down Expand Up @@ -28314,7 +28318,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
if (!output.endsWith('\n')) {
output += '\n'
}
output += `[${latestTag.name}]: ${githubServerUrl}/${owner}/${repo}/compare/${previousTag.name}...${latestTag.name}\n`
const outputLink = includeLinksToGithub ? `${githubServerUrl}/${owner}/${repo}/compare/${previousTag.name}...${latestTag.name}\n` : ''
output += `[${latestTag.name}]: ${outputLink}\n`

// WRITE CHANGELOG TO FILE

Expand All @@ -28327,4 +28332,4 @@ main()

module.exports = __webpack_exports__;
/******/ })()
;
;
18 changes: 11 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ async function main () {
const useGitmojis = core.getBooleanInput('useGitmojis')
const includeInvalidCommits = core.getBooleanInput('includeInvalidCommits')
const reverseOrder = core.getBooleanInput('reverseOrder')
const includeLinksToGithub = core.getBooleanInput('includeLinksToGithub')
const gh = github.getOctokit(token)
const owner = github.context.repo.owner
const repo = github.context.repo.repo
Expand Down Expand Up @@ -247,8 +248,9 @@ async function main () {
owner,
repo
})
changesFile.push(`- due to [\`${breakChange.sha.substring(0, 7)}\`](${breakChange.url}) - ${subjectFile.output}:\n\n${body}\n`)
changesVar.push(`- due to [\`${breakChange.sha.substring(0, 7)}\`](${breakChange.url}) - ${subjectVar.output}:\n\n${body}\n`)
const linkToBreakingChange = includeLinksToGithub ? `- [\`${breakChange.sha.substring(0, 7)}\`](${breakChange.url}) - ` : ''
changesFile.push(`- due to ${linkToBreakingChange}${subjectFile.output}:\n\n${body}\n`)
changesVar.push(`- due to ${linkToBreakingChange}${subjectVar.output}:\n\n${body}\n`)
}
idx++
}
Expand Down Expand Up @@ -304,8 +306,9 @@ async function main () {
owner,
repo
})
changesFile.push(`- [\`${commit.sha.substring(0, 7)}\`](${commit.url}) - ${scope}${subjectFile.output}`)
changesVar.push(`- [\`${commit.sha.substring(0, 7)}\`](${commit.url}) - ${scope}${subjectVar.output}`)
const linkToCommit = includeLinksToGithub ? `- [\`${commit.sha.substring(0, 7)}\`](${commit.url})` : ''
changesFile.push(`${linkToCommit} - ${scope}${subjectFile.output}`)
changesVar.push(`${linkToCommit} - ${scope}${subjectVar.output}`)

if (includeRefIssues && subjectVar.prs.length > 0) {
for (const prId of subjectVar.prs) {
Expand Down Expand Up @@ -337,11 +340,12 @@ async function main () {
const relIssues = _.get(issuesRaw, 'repository.pullRequest.closingIssuesReferences.nodes')
for (const relIssue of relIssues) {
const authorLogin = _.get(relIssue, 'author.login')
const linkToRelIssue = includeLinksToGithub ? `[#${relIssue.number}](${relIssue.url})` : `#${relIssue.number}`
if (authorLogin) {
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue [#${relIssue.number}](${relIssue.url}) opened by [@${authorLogin}](${relIssue.author.url})*`)
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue ${linkToRelIssue} opened by [@${authorLogin}](${relIssue.author.url})*`)
changesVar.push(` - :arrow_lower_right: *${relIssuePrefix} issue #${relIssue.number} opened by @${authorLogin}*`)
} else {
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue [#${relIssue.number}](${relIssue.url})*`)
changesFile.push(` - :arrow_lower_right: *${relIssuePrefix} issue ${linkToRelIssue}*`)
changesVar.push(` - :arrow_lower_right: *${relIssuePrefix} issue #${relIssue.number}*`)
}
}
Expand Down Expand Up @@ -402,7 +406,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
output += '\n' + lines.slice(firstVersionLine).join('\n')
}

// add newline character at end of output if it doesn't already exists
// add newline character at end of output if it doesn't already exist
if (!output.endsWith('\n')) {
output += '\n'
}
Expand Down