Skip to content
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 dev-docs/changelog.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ links:
We have two gradle tasks that bootstraps a YAML file in the `changelog/unreleased/` directory.
`writeChangeLog` will infer the JIRA id from the current branch if possible, otherwise you'll need to add the JIRA link manually.
If the change isn't worth a JIRA yet a changelog would still be nice, use `writeChangelogPr` after you've created the PR. It will incorporate a link to the PR in the entry.
If `writeChangelogPr` can't auto-detect the PR for your current branch (e.g. `gh` can't correlate a differently-named local branch to it), pass the PR explicitly: `./gradlew writeChangelogPr -Ppr=4677` or `-Ppr=https://github.com/apache/solr/pull/4677`.

Invoke the task with:

Expand Down
11 changes: 8 additions & 3 deletions gradle/changelog.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,18 @@ task newChangelog {
}

task writeChangelogPr {
description = 'Generates a changelog entry file (YAML) for the current GitHub PR'
description = 'Generates a changelog entry file (YAML) for the current GitHub PR. ' +
'Pass -Ppr=<number-or-url> if the PR cannot be auto-detected from the current branch.'
doLast {
def ctx = changelogSetup()
def prInfoProc = ['gh', 'pr', 'view', '--json', 'number,title'].execute()
def prArg = providers.gradleProperty("pr").getOrNull()
def prCommand = prArg ? ['gh', 'pr', 'view', prArg, '--json', 'number,title'] :
['gh', 'pr', 'view', '--json', 'number,title']
def prInfoProc = prCommand.execute()
prInfoProc.waitFor()
if (prInfoProc.exitValue() != 0) {
throw new GradleException("Could not find a GitHub PR for branch '${ctx.gitBranch}'. Make sure you've pushed this branch and created a PR.\n${prInfoProc.err.text.trim()}")
def target = prArg ? "PR '${prArg}'" : "a GitHub PR for branch '${ctx.gitBranch}'"
throw new GradleException("Could not find ${target}. Make sure you've pushed this branch and created a PR, or pass -Ppr=<number-or-url>.\n${prInfoProc.err.text.trim()}")
}
def prJson = new groovy.json.JsonSlurper().parseText(prInfoProc.text)
def prNumber = prJson.number
Expand Down
Loading