Skip to content

Commit

Permalink
Merge branch 'release/4.10' into release/4.11-alpha
Browse files Browse the repository at this point in the history
# Conflicts:
#	ontrack-web-core/components/form/FormDialog.js
  • Loading branch information
dcoraboeuf committed Dec 8, 2024
2 parents e58e50a + 1a4c0c4 commit 0cbc824
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class AutoVersioningProcessingServiceImpl(
}
// Map of current versions per path
val currentVersions = mutableMapOf<String, String>()
// Caching the updated content of each path
val updatedContent = mutableMapOf<String, List<String>>()
// For each target path
val targetPathUpdated: List<Boolean> = try {
order.allPaths.flatMap { configPath ->
Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 8 additions & 6 deletions ontrack-web-core/components/charts/CountChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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}) => {
Expand All @@ -62,7 +64,7 @@ export default function CountChart({query, variables, yTickFormatter}) {
>
<CartesianGrid strokeDasharray="3 3"/>
<XAxis dataKey="date" angle={-45} tickMargin={30} height={80} interval="preserveStart"/>
<YAxis tickFormatter={yTickFormatter}/>
<YAxis tickFormatter={yTickFormatter} domain={domain}/>
<Tooltip/>
<Legend formatter={legendFormatter} onClick={legendClick} style={{cursor: 'pointer'}}/>
<Bar dataKey="value" fill="#6666aa" hide={inactiveSeries.includes('value')}/>
Expand Down
4 changes: 3 additions & 1 deletion ontrack-web-core/components/charts/PercentageChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export default function PercentageChart({query, variables}) {
<CountChart
query={query}
variables={variables}
yTickFormatter={percentageFormatter()}
yTickFormatter={percentageFormatter}
legendFormatter={() => "%"}
domain={[0, 100]}
/>
</>
)
Expand Down
2 changes: 1 addition & 1 deletion ontrack-web-core/components/form/FormDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default function FormDialog({dialog, onValuesChange, children, hasOk = tr
</Button>
{
hasOk &&
<Button type="primary" htmlType="submit" disabled={!submittable}>
<Button loading={loading} type="primary" htmlType="submit" disabled={loading || !submittable}>
{okText ?? "OK"}
</Button>
}
Expand Down

0 comments on commit 0cbc824

Please sign in to comment.