janhoy commented on code in PR #3820:
URL: https://github.com/apache/solr/pull/3820#discussion_r2476213990
##########
gradle/changelog.gradle:
##########
@@ -25,19 +25,26 @@ logchange {
task writeChangelog {
description = 'Generates a change/log description file (YAML)'
doLast {
+ def gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
+
+ // Prevent running on main or branches prefixed with 'branch_'
+ if (gitBranch == 'main' || gitBranch.startsWith('branch_')) {
+ throw new GradleException("Cannot create changelog on branch
'${gitBranch}'. This task should only be run on feature branches.")
+ }
+
def gitUserName = 'git config user.name'.execute().text.trim()
def configuredName =
providers.gradleProperty("user.name").getOrElse(gitUserName)
def githubId = providers.gradleProperty("user.githubid").getOrElse(null)
def nick = githubId ? "\n nick: ${githubId}" : ""
def asfId = providers.gradleProperty("user.asfid").getOrElse(null)
def asfIdUrl = asfId ? "\n url:
https://home.apache.org/phonebook.html?uid=${asfId}" : ""
- def gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
def jiraMatcher = gitBranch.toUpperCase() =~ /SOLR-\d\d\d+/
def jiraRef = jiraMatcher ? jiraMatcher[0] : "SOLR-XXXX"
def jiraUrl = "https://issues.apache.org/jira/browse/${jiraRef}"
def jiraLinks = jiraMatcher ? "links:\n - name: ${jiraRef}\n url:
${jiraUrl}" : ""
def branchWithoutJira = gitBranch.replaceFirst(/(?i)SOLR-\d\d\d+-/,
"").replace("-", " ").capitalize()
- def fileName = "changelog/unreleased/${gitBranch}.yml"
+ def sanitizedBranchName = gitBranch.replace("/",
"-").replaceAll(/[^a-zA-Z0-9._-]/, "-")
Review Comment:
Incorporated some of your code with case insensitive matcher and $title var
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]