Skip to content

Commit 732fa5d

Browse files
committed
SOLR-17619 Cleanup after logchange cutover (#3820)
* SOLR-17619 Cleanup after logchange cutover * Exclude generated archive.md files from license checks * Fix generate-filename * Incorporate David's suggestion. * Fixes precommit Fixes #3818 (cherry picked from commit fb74fa8)
1 parent bb5fe63 commit 732fa5d

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

changelog/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
1616
-->
17-
# New changelog process
17+
# Apache Solr Changelog
1818

19-
We are in the process of migrating to a new way of managing our changelog. Please see [dev-docs/changelog.adoc](../dev-docs/changelog.adoc) for details.
20-
21-
In a transition period it is still possible to merge your changelog entry to `solr/CHANGES.txt`, but then you can only use the new process.
19+
This is the home of the Solr changelog, in logchange format.
20+
Please see [dev-docs/changelog.adoc](../dev-docs/changelog.adoc) for details.

changelog/unreleased/PR#3778.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ type: added # added, changed, fixed, deprecated, removed, dependency_update, sec
44
authors:
55
- name: Eric Pugh
66
- name: Andreas Rütten
7-
merge_requests:
7+
issues:
88
- 3778

dev-docs/changelog.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ solr/
3030
└── changelog/
3131
├── unreleased/ ← new fragments live here
3232
| └── SOLR-12345-fix-memory-leak.yml
33-
├── v10.0.0/ ← changes in already released version
34-
└── v10.0.1/
33+
├── v9.8.0/ ← changes in already released versions
34+
├── v9.8.0/
35+
└── v9.9.0/
3536
----
3637

3738
== 3. The YAML format
3839

39-
Below is an example of a changelog yaml fragment. The full yaml format is xref:https://logchange.dev/tools/logchange/reference/#tasks[documented here], but we normally only need `title`, `type`, `authors` and `links`:
40+
Below is an example of a changelog yaml fragment. The full yaml format is xref:https://logchange.dev/tools/logchange/reference/#tasks[documented here], but we normally only need `title`, `type`, `authors` and `links`. For a change without a JIRA, you can add the PR number in `issues`:
4041

4142
[source, yaml]
4243
----

gradle/changelog.gradle

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,33 @@ logchange {
2525
task writeChangelog {
2626
description = 'Generates a change/log description file (YAML)'
2727
doLast {
28+
def gitBranchFull = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
29+
30+
// Prevent running on main or branches prefixed with 'branch_'
31+
if (gitBranchFull == 'main' || gitBranchFull.startsWith('branch_')) {
32+
throw new GradleException("Cannot create changelog on branch '${gitBranchFull}'. This task should only be run on feature branches.")
33+
}
34+
35+
def gitBranch = gitBranchFull.replaceFirst(/^.*\//, "")
36+
2837
def gitUserName = 'git config user.name'.execute().text.trim()
2938
def configuredName = providers.gradleProperty("user.name").getOrElse(gitUserName)
3039
def githubId = providers.gradleProperty("user.githubid").getOrElse(null)
3140
def nick = githubId ? "\n nick: ${githubId}" : ""
3241
def asfId = providers.gradleProperty("user.asfid").getOrElse(null)
3342
def asfIdUrl = asfId ? "\n url: https://home.apache.org/phonebook.html?uid=${asfId}" : ""
34-
def gitBranch = 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
35-
def jiraMatcher = gitBranch.toUpperCase() =~ /SOLR-\d\d\d+/
36-
def jiraRef = jiraMatcher ? jiraMatcher[0] : "SOLR-XXXX"
43+
def jiraMatcher = gitBranch =~ /(?i)SOLR-\d\d\d+/
44+
def jiraRef = jiraMatcher ? jiraMatcher[0].toUpperCase() : "SOLR-XXXX"
3745
def jiraUrl = "https://issues.apache.org/jira/browse/${jiraRef}"
3846
def jiraLinks = jiraMatcher ? "links:\n - name: ${jiraRef}\n url: ${jiraUrl}" : ""
39-
def branchWithoutJira = gitBranch.replaceFirst(/(?i)SOLR-\d\d\d+-/, "").replace("-", " ").capitalize()
40-
def fileName = "changelog/unreleased/${gitBranch}.yml"
47+
def title = gitBranch.replaceFirst(/(?i)SOLR-\d\d\d+-/, "").replace("-", " ").capitalize()
48+
// Strip everything before and including '/', then sanitize special characters
49+
def sanitizedBranchName = gitBranch.replaceAll(/^.*\//, "").replaceAll(/[^a-zA-Z0-9._-]/, "-")
50+
def fileName = "changelog/unreleased/${sanitizedBranchName}.yml"
4151
def file = new File(fileName)
4252
file.parentFile.mkdirs()
4353
file.text = """# See https://github.com/apache/solr/blob/main/dev-docs/changelog.adoc
44-
title: ${branchWithoutJira}
54+
title: ${title}
4555
type: other # added, changed, fixed, deprecated, removed, dependency_update, security, other
4656
authors:
4757
- name: ${configuredName}${nick}${asfIdUrl}

gradle/validation/rat-sources.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ allprojects {
100100
exclude "CHANGELOG.md"
101101
exclude "changelog/**/version-summary.md"
102102
exclude "changelog/.templates/*.md"
103+
exclude "changelog/archive.md"
103104

104105
// The root project also includes patterns for the include composite
105106
// projects. Include their sources in the scan.

0 commit comments

Comments
 (0)