mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJI-9: sync icons only from changes to IntelliJIcons from IDEA
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
package org.jetbrains.intellij.build.images.sync
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
@@ -40,6 +41,7 @@ internal class Context(private val errorHandler: Consumer<String> = Consumer { e
|
||||
addedByDev + removedByDev + modifiedByDev
|
||||
}
|
||||
val iconsCommitHashesToSync: Set<String>
|
||||
val devIconsCommitHashesToSync: Set<String>
|
||||
|
||||
fun iconsSyncRequired() = devChanges.isNotEmpty()
|
||||
fun devSyncRequired() = iconsChanges.isNotEmpty()
|
||||
@@ -102,6 +104,15 @@ internal class Context(private val errorHandler: Consumer<String> = Consumer { e
|
||||
?.split(",", ";", " ")
|
||||
?.filter { it.isNotBlank() }
|
||||
?.mapTo(mutableSetOf(), String::trim) ?: emptySet()
|
||||
devIconsCommitHashesToSync = System.getProperty("teamcity.build.changedFiles.file")
|
||||
?.let(::File)
|
||||
?.takeIf(File::exists)
|
||||
?.let(FileUtil::loadFile)
|
||||
?.takeIf { !it.contains("<personal>") }
|
||||
?.also { log("Changes from TeamCity: $it") }
|
||||
?.let(StringUtil::splitByLines)
|
||||
?.map { it.split(':')[2] }
|
||||
?.toSet() ?: emptySet()
|
||||
doSyncIconsRepo = bool(syncIconsArg)
|
||||
doSyncDevRepo = bool(syncDevIconsArg)
|
||||
doSyncRemovedIconsInDev = bool(syncRemovedIconsInDevArg) || iconsCommitHashesToSync.isNotEmpty()
|
||||
|
||||
+26
-11
@@ -32,11 +32,10 @@ internal fun checkIcons(context: Context = Context(), loggerImpl: Consumer<Strin
|
||||
val devRepoVcsRoots = vcsRoots(context.devRepoRoot)
|
||||
context.devIcons = readDevRepo(context.devRepoRoot, context.devRepoDir, devRepoVcsRoots, context.skipDirsPattern)
|
||||
callWithTimer("Searching for changed icons..") {
|
||||
if (context.iconsCommitHashesToSync.isNotEmpty()) {
|
||||
searchForChangedIconsByDesigners(context)
|
||||
}
|
||||
else {
|
||||
searchForAllChangedIcons(context, devRepoVcsRoots)
|
||||
when {
|
||||
context.iconsCommitHashesToSync.isNotEmpty() -> searchForChangedIconsByDesigners(context)
|
||||
context.devIconsCommitHashesToSync.isNotEmpty() -> searchForChangedIconsByDev(context, devRepoVcsRoots)
|
||||
else -> searchForAllChangedIcons(context, devRepoVcsRoots)
|
||||
}
|
||||
}
|
||||
syncIcons(context)
|
||||
@@ -86,16 +85,32 @@ private fun searchForAllChangedIcons(context: Context, devRepoVcsRoots: Collecti
|
||||
}
|
||||
}
|
||||
|
||||
private fun asIcon(files: Collection<String>, repo: File, root: File) = files
|
||||
.filter { ImageExtension.fromName(it) != null }
|
||||
.map { repo.resolve(it).toRelativeString(root) }
|
||||
|
||||
private fun searchForChangedIconsByDesigners(context: Context) {
|
||||
fun check(files: Collection<String>) = files
|
||||
.filter { ImageExtension.fromName(it) != null }
|
||||
.map { context.iconsRepo.resolve(it).toRelativeString(context.iconsRepoDir) }
|
||||
log("${context.iconsRepoName} changes from commits ${context.iconsCommitHashesToSync.joinToString()}")
|
||||
context.iconsCommitHashesToSync.forEach { commit ->
|
||||
changesFromCommit(context.iconsRepo, commit).forEach { type, files ->
|
||||
when (type) {
|
||||
ChangeType.ADDED -> context.addedByDesigners += check(files)
|
||||
ChangeType.MODIFIED -> context.modifiedByDesigners += check(files)
|
||||
ChangeType.DELETED -> context.removedByDesigners += check(files)
|
||||
ChangeType.ADDED -> context.addedByDesigners += asIcon(files, context.iconsRepo, context.iconsRepoDir)
|
||||
ChangeType.MODIFIED -> context.modifiedByDesigners += asIcon(files, context.iconsRepo, context.iconsRepoDir)
|
||||
ChangeType.DELETED -> context.removedByDesigners += asIcon(files, context.iconsRepo, context.iconsRepoDir)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun searchForChangedIconsByDev(context: Context, devRepoVcsRoots: List<File>) {
|
||||
log("${context.devRepoName} changes from commits ${context.devIconsCommitHashesToSync.joinToString()}")
|
||||
context.devIconsCommitHashesToSync.forEach { commit ->
|
||||
val repo = devRepoVcsRoots.first { commitInfo(it, commit) != null }
|
||||
changesFromCommit(repo, commit).forEach { type, files ->
|
||||
when (type) {
|
||||
ChangeType.ADDED -> context.addedByDev.addAll(asIcon(files, repo, context.devRepoRoot))
|
||||
ChangeType.MODIFIED -> context.modifiedByDev.addAll(asIcon(files, repo, context.devRepoRoot))
|
||||
ChangeType.DELETED -> context.removedByDev.addAll(asIcon(files, repo, context.devRepoRoot))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ private fun head(repo: File): String {
|
||||
return heads[repo]!!
|
||||
}
|
||||
|
||||
private fun commitInfo(repo: File, vararg args: String): CommitInfo? {
|
||||
internal fun commitInfo(repo: File, vararg args: String): CommitInfo? {
|
||||
val output = execute(repo, GIT, "log", "--max-count", "1", "--format=%H/%cd/%P/%ce/%s", "--date=raw", *args)
|
||||
.splitNotBlank("/")
|
||||
// <hash>/<timestamp> <timezone>/<parent hashes>/committer email/<subject>
|
||||
|
||||
Reference in New Issue
Block a user