This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 1476125a0e2 build: writeChangelogPr pr option (#4685)
1476125a0e2 is described below

commit 1476125a0e2b3ccec11fea8296a684aa9f5373d5
Author: David Smiley <[email protected]>
AuthorDate: Wed Aug 12 15:01:18 2026 -0400

    build: writeChangelogPr pr option (#4685)
    
    to explicitly indicate the PR
---
 dev-docs/changelog.adoc |  1 +
 gradle/changelog.gradle | 11 ++++++++---
 2 files changed, 9 insertions(+), 3 deletions(-)

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=<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

Reply via email to