-
Notifications
You must be signed in to change notification settings - Fork 69
Stop supporting case insensitive file names #237
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fzhinkin
merged 3 commits into
develop
from
231-stop-supporting-case-insensitive-file-names
Jun 6, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,11 @@ package kotlinx.validation | |
import com.github.difflib.DiffUtils | ||
import com.github.difflib.UnifiedDiffUtils | ||
import java.io.* | ||
import java.util.TreeMap | ||
import javax.inject.Inject | ||
import org.gradle.api.* | ||
import org.gradle.api.file.* | ||
import org.gradle.api.model.ObjectFactory | ||
import org.gradle.api.tasks.* | ||
|
||
public open class KotlinApiCompareTask @Inject constructor(private val objects: ObjectFactory): DefaultTask() { | ||
public open class KotlinApiCompareTask @Inject constructor(): DefaultTask() { | ||
|
||
@InputFiles | ||
@PathSensitive(PathSensitivity.RELATIVE) | ||
|
@@ -41,43 +38,17 @@ public open class KotlinApiCompareTask @Inject constructor(private val objects: | |
} | ||
val subject = projectName | ||
|
||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hurray! ) |
||
* We use case-insensitive comparison to workaround issues with case-insensitive OSes | ||
* and Gradle behaving slightly different on different platforms. | ||
* We neither know original sensitivity of existing .api files, not | ||
* build ones, because projectName that is part of the path can have any sensitvity. | ||
* To workaround that, we replace paths we are looking for the same paths that | ||
* actually exist on FS. | ||
*/ | ||
fun caseInsensitiveMap() = TreeMap<String, RelativePath> { rp, rp2 -> | ||
rp.compareTo(rp2, true) | ||
} | ||
|
||
val apiBuildDirFiles = caseInsensitiveMap() | ||
val expectedApiFiles = caseInsensitiveMap() | ||
|
||
objects.fileTree().from(buildApiDir).visit { file -> | ||
apiBuildDirFiles[file.name] = file.relativePath | ||
} | ||
objects.fileTree().from(projectApiDir).visit { file -> | ||
expectedApiFiles[file.name] = file.relativePath | ||
} | ||
|
||
if (!expectedApiFiles.containsKey(projectApiFile.name)) { | ||
if (!projectApiFile.exists()) { | ||
error("File ${projectApiFile.name} is missing from ${projectApiDir.relativeDirPath()}, please run " + | ||
":$subject:apiDump task to generate one") | ||
} | ||
if (!apiBuildDirFiles.containsKey(generatedApiFile.name)) { | ||
if (!generatedApiFile.exists()) { | ||
error("File ${generatedApiFile.name} is missing from dump results.") | ||
} | ||
|
||
// Normalize case-sensitivity | ||
val expectedApiDeclaration = expectedApiFiles.getValue(projectApiFile.name) | ||
val actualApiDeclaration = apiBuildDirFiles.getValue(generatedApiFile.name) | ||
val diffSet = mutableSetOf<String>() | ||
val expectedFile = expectedApiDeclaration.getFile(projectApiDir) | ||
val actualFile = actualApiDeclaration.getFile(buildApiDir) | ||
val diff = compareFiles(expectedFile, actualFile) | ||
val diff = compareFiles(projectApiFile, generatedApiFile) | ||
if (diff != null) diffSet.add(diff) | ||
if (diffSet.isNotEmpty()) { | ||
val diffText = diffSet.joinToString("\n\n") | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are the tests run on different systems at once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are running on Windows/Linux/MacOS from time to time, yes.