diff --git a/ontrack-extension-auto-versioning/src/main/java/net/nemerosa/ontrack/extension/av/processing/AutoVersioningProcessingServiceImpl.kt b/ontrack-extension-auto-versioning/src/main/java/net/nemerosa/ontrack/extension/av/processing/AutoVersioningProcessingServiceImpl.kt index d0ad18aa2d..613de3d595 100644 --- a/ontrack-extension-auto-versioning/src/main/java/net/nemerosa/ontrack/extension/av/processing/AutoVersioningProcessingServiceImpl.kt +++ b/ontrack-extension-auto-versioning/src/main/java/net/nemerosa/ontrack/extension/av/processing/AutoVersioningProcessingServiceImpl.kt @@ -97,6 +97,8 @@ class AutoVersioningProcessingServiceImpl( } // Map of current versions per path val currentVersions = mutableMapOf() + // Caching the updated content of each path + val updatedContent = mutableMapOf>() // For each target path val targetPathUpdated: List = try { order.allPaths.flatMap { configPath -> @@ -119,10 +121,12 @@ class AutoVersioningProcessingServiceImpl( } configPath.paths.map { targetPath -> // Gets the content of the target file - val lines = scm.download(scmBranch, targetPath, retryOnNotFound = true) - ?.toString(Charsets.UTF_8) - ?.lines() - ?: throw AutoVersioningNoContentException(scmBranch, targetPath) + val lines = updatedContent.getOrPut(targetPath) { + scm.download(scmBranch, targetPath, retryOnNotFound = true) + ?.toString(Charsets.UTF_8) + ?.lines() + ?: throw AutoVersioningNoContentException(scmBranch, targetPath) + } // Gets the current version in this file val currentVersion: String = autoVersioningTargetFileService.readVersion(configPath, lines) ?: throw AutoVersioningVersionNotFoundException(targetPath) @@ -134,14 +138,8 @@ class AutoVersioningProcessingServiceImpl( val updatedLines = configPath.replaceVersion(lines, targetVersion) // Audit autoVersioningAuditService.onProcessingUpdatingFile(order, upgradeBranch, targetPath) - // Uploads of the file content - scm.uploadLines( - upgradeBranch, - commitId, - targetPath, - updatedLines, - message = order.getCommitMessage() - ) + // Updating the cache + updatedContent[targetPath] = updatedLines // Changed true } else { @@ -161,6 +159,26 @@ class AutoVersioningProcessingServiceImpl( // At least one path was changed if (targetPathUpdated.any { it }) { + // Uploading the file contents + try { + updatedContent.forEach { (targetPath, updatedLines) -> + scm.uploadLines( + upgradeBranch, + commitId, + targetPath, + updatedLines, + message = order.getCommitMessage() + ) + } + } catch (e: Exception) { + autoVersioningEventService.sendError( + order, + e.message?.takeIf { it.isNotBlank() } ?: "Issue while uploading the change", + e + ) + throw e + } + // Templating renderer val avRenderer = autoVersioningTemplatingService.createAutoVersioningTemplateRenderer( order = order, diff --git a/ontrack-kdsl-acceptance/src/test/java/net/nemerosa/ontrack/kdsl/acceptance/tests/av/ACCAutoVersioningMultiplePaths.kt b/ontrack-kdsl-acceptance/src/test/java/net/nemerosa/ontrack/kdsl/acceptance/tests/av/ACCAutoVersioningMultiplePaths.kt index 82a7190f06..3183b02545 100644 --- a/ontrack-kdsl-acceptance/src/test/java/net/nemerosa/ontrack/kdsl/acceptance/tests/av/ACCAutoVersioningMultiplePaths.kt +++ b/ontrack-kdsl-acceptance/src/test/java/net/nemerosa/ontrack/kdsl/acceptance/tests/av/ACCAutoVersioningMultiplePaths.kt @@ -73,6 +73,62 @@ class ACCAutoVersioningMultiplePaths : AbstractACCAutoVersioningTestSupport() { } } + @Test + fun `Auto versioning with additional paths using the same path`() { + withMockScmRepository(ontrack) { + withAutoVersioning { + repositoryFile("gradle.properties") { + """ + one-version = 1.0.0 + another-version = 1.0.0 + """.trimIndent() + } + val dependency = branchWithPromotion(promotion = "IRON") + project { + branch { + configuredForMockRepository() + setAutoVersioningConfig( + listOf( + AutoVersioningSourceConfig( + sourceProject = dependency.project.name, + sourceBranch = dependency.name, + sourcePromotion = "IRON", + targetPath = "gradle.properties", + targetProperty = "one-version", + additionalPaths = listOf( + AutoVersioningSourceConfigPath( + path = "gradle.properties", + property = "another-version", + ) + ) + ) + ) + ) + + dependency.apply { + build(name = "2.0.0") { + setMetaInfoProperty("toml", "2.0.0-toml") + promote("IRON") + } + } + + waitForAutoVersioningCompletion() + + assertThatMockScmRepository { + fileContains("gradle.properties") { + """ + one-version = 2.0.0 + another-version = 2.0.0 + """.trimIndent() + } + } + + } + } + } + } + } + @Test fun `Auto versioning on multiple paths`() { withMockScmRepository(ontrack) { diff --git a/ontrack-web-core/components/charts/CountChart.js b/ontrack-web-core/components/charts/CountChart.js index 79f194488e..bf2737a60f 100644 --- a/ontrack-web-core/components/charts/CountChart.js +++ b/ontrack-web-core/components/charts/CountChart.js @@ -3,7 +3,13 @@ import {useEffect, useState} from "react"; import {Bar, CartesianGrid, ComposedChart, Legend, Tooltip, XAxis, YAxis} from "recharts"; import ChartContainer from "@components/charts/ChartContainer"; -export default function CountChart({query, variables, yTickFormatter}) { +export default function CountChart({ + query, + variables, + yTickFormatter, + legendFormatter = () => "Count ", + domain, + }) { const client = useGraphQLClient() @@ -40,10 +46,6 @@ export default function CountChart({query, variables, yTickFormatter}) { } }, [client, query, variables]); - const legendFormatter = (value, entry, index) => { - return "Count" - } - const [inactiveSeries, setInactiveSeries] = useState([]) const legendClick = ({dataKey}) => { @@ -62,7 +64,7 @@ export default function CountChart({query, variables, yTickFormatter}) { > - + diff --git a/ontrack-web-core/components/charts/PercentageChart.js b/ontrack-web-core/components/charts/PercentageChart.js index 24c829a2be..32374dcca3 100644 --- a/ontrack-web-core/components/charts/PercentageChart.js +++ b/ontrack-web-core/components/charts/PercentageChart.js @@ -8,7 +8,9 @@ export default function PercentageChart({query, variables}) { "%"} + domain={[0, 100]} /> ) diff --git a/ontrack-web-core/components/form/FormDialog.js b/ontrack-web-core/components/form/FormDialog.js index 2a60b6c932..df2de13320 100644 --- a/ontrack-web-core/components/form/FormDialog.js +++ b/ontrack-web-core/components/form/FormDialog.js @@ -142,7 +142,7 @@ export default function FormDialog({dialog, onValuesChange, children, hasOk = tr { hasOk && - }