Skip to content

Commit 80d3ffc

Browse files
Copilotxiang17
andauthored
Make more-licenses.md deterministic by removing generated timestamp noise (#4802)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: xiang17 <9310587+xiang17@users.noreply.github.com> Co-authored-by: Sean Li <xili9@microsoft.com>
1 parent e38f3cf commit 80d3ffc

4 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎.github/workflows/build-common.yml‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,15 @@ jobs:
6464
run: |
6565
# add any untracked folders that may have been added by generateLicenseReport
6666
git add licenses
67-
# there's always going to one line difference due to the timestamp included in the report
68-
if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]]
67+
if git diff --cached --quiet licenses
6968
then
7069
echo "Licenses are up-to-date."
7170
else
7271
echo "Licenses are not up-to-date, please run './gradlew generateLicenseReport' locally and commit."
7372
echo
74-
echo "$(git diff --cached --stat licenses)"
73+
git diff --cached --stat licenses
7574
echo
76-
echo "$(git diff --cached licenses)"
75+
git diff --cached licenses
7776
exit 1
7877
fi
7978

‎.github/workflows/pull-request-helper.yml‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,7 @@ jobs:
4444
run: |
4545
./gradlew generateLicenseReport
4646
git add licenses
47-
# there's always going to one line difference due to the timestamp included in the report
48-
if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]]
49-
then
50-
git reset HEAD licenses
51-
git checkout -- licenses
47+
if git diff --cached --quiet; then
5248
exit 0 # success
5349
fi
5450
git commit -m "./gradlew generateLicenseReport"

‎agent/agent/build.gradle.kts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22
import com.github.jk1.license.filter.LicenseBundleNormalizer
33
import com.github.jk1.license.render.InventoryMarkdownReportRenderer
4+
import java.nio.charset.StandardCharsets
45

56
plugins {
67
id("com.github.jk1.dependency-license-report")
@@ -169,6 +170,22 @@ tasks {
169170
named("generateLicenseReport").configure {
170171
dependsOn(cleanLicenses)
171172
finalizedBy(":spotlessApply")
173+
doLast {
174+
val reportFile = rootProject.file("licenses/more-licenses.md")
175+
if (reportFile.exists()) {
176+
val reportContents = reportFile.readText(StandardCharsets.UTF_8)
177+
val normalizedReportContents =
178+
reportContents.replace(
179+
Regex(
180+
"""(?m)(^## Dependency License Report\r?\n)_\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[^\r\n]*_\r?\n"""
181+
),
182+
"$1",
183+
)
184+
if (normalizedReportContents != reportContents) {
185+
reportFile.writeText(normalizedReportContents, StandardCharsets.UTF_8)
186+
}
187+
}
188+
}
172189
// disable licence report generation unless this task is explicitly run
173190
// the files produced by this task are used by other tasks without declaring them as dependency
174191
// which gradle considers an error

‎licenses/more-licenses.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
# agent
33
## Dependency License Report
4-
_2026-07-29 22:55:05 UTC_
54
## Apache License, Version 2.0
65

76
**1** **Group:** `com.fasterxml.jackson.core` **Name:** `jackson-annotations` **Version:** `2.22`

0 commit comments

Comments
 (0)