File tree Expand file tree Collapse file tree 3 files changed +46
-2
lines changed 
main/kotlin/org/jlleitschuh/gradle/ktlint 
test/kotlin/org/jlleitschuh/gradle/ktlint Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
1111
1212-    fix new ktlint errors that come from our new default version of ktlint [ #651  ] ( https://github.com/JLLeitschuh/ktlint-gradle/pull/651 ) 
1313-    fix syntax bug in release logic for VERSION_LATEST_RELEASE.txt [ #651  ] ( https://github.com/JLLeitschuh/ktlint-gradle/pull/651 ) 
14+ -    fix isRootEditorConfig [ #664  ] ( https://github.com/JLLeitschuh/ktlint-gradle/pull/664 ) 
1415
1516### Changed  
1617
Original file line number Diff line number Diff line change @@ -70,9 +70,9 @@ private tailrec fun searchEditorConfigFiles(
7070    }
7171}
7272
73- private  val  editorConfigRootRegex =  " ^root\\ s?=\\ s?true\\ R "  .toRegex()
73+ private  val  editorConfigRootRegex =  " ^root\\ s?=\\ s?true"  .toRegex()
7474
75- private  fun  Path.isRootEditorConfig (): Boolean  {
75+ internal  fun  Path.isRootEditorConfig (): Boolean  {
7676    if  (! Files .exists(this ) ||  ! Files .isReadable(this )) return  false 
7777
7878    toFile().useLines { lines -> 
Original file line number Diff line number Diff line change 1+ package  org.jlleitschuh.gradle.ktlint 
2+ 
3+ import  org.junit.jupiter.api.Assertions 
4+ import  org.junit.jupiter.api.Test 
5+ import  org.junit.jupiter.api.io.TempDir 
6+ import  java.io.File 
7+ 
8+ internal  class  PluginUtilTest  {
9+     @TempDir
10+     lateinit  var  temporaryFolder:  File 
11+ 
12+     @Test
13+     fun  `test isRootEditorConfig returns true`  () {
14+         temporaryFolder.resolve(" test-pos.txt"  ).apply  {
15+             createNewFile()
16+             writeText(
17+                 """ 
18+                 root=true 
19+                 """  .trimIndent()
20+             )
21+             Assertions .assertTrue(this .toPath().isRootEditorConfig()) {
22+                 " correctly detects root" 
23+             }
24+             delete()
25+         }
26+     }
27+ 
28+     @Test
29+     fun  `test isRootEditorConfig returns false`  () {
30+         temporaryFolder.resolve(" test-neg.txt"  ).apply  {
31+             createNewFile()
32+             writeText(
33+                 """ 
34+                 [*.kt] 
35+                 """  .trimIndent()
36+             )
37+             Assertions .assertFalse(this .toPath().isRootEditorConfig()) {
38+                 " correctly does not match non-root file" 
39+             }
40+             delete()
41+         }
42+     }
43+ }
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments