diff --git a/dev-docs/changelog.adoc b/dev-docs/changelog.adoc index 884509f9ec7..0a0e9e5a1bd 100644 --- a/dev-docs/changelog.adoc +++ b/dev-docs/changelog.adoc @@ -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: diff --git a/gradle/changelog.gradle b/gradle/changelog.gradle index c4120d7c257..f69ac7aa896 100644 --- a/gradle/changelog.gradle +++ b/gradle/changelog.gradle @@ -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= 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=.\n${prInfoProc.err.text.trim()}") } def prJson = new groovy.json.JsonSlurper().parseText(prInfoProc.text) def prNumber = prJson.number