-
Notifications
You must be signed in to change notification settings - Fork 118
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
Allow blob, tilde and env vars in app paths #386
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
db47575
Implemented evaluating paths #336
sravanmedarapu 3cf9411
Fixed failing tests
sravanmedarapu 73304dd
Added unit tests
sravanmedarapu 45559a7
WIP path evaluation fixes
bootstraponline ed6c617
Implemented evaluating paths #336
sravanmedarapu 0ff99a3
Path evaluation fixes
bootstraponline a841b81
Move file path tests to ArgsHelperFilePath
bootstraponline 51a2fa5
Update ArgsFileVisitor
bootstraponline bb884d7
Remove unused environmentVariables rule
bootstraponline 95fba21
Merge remote-tracking branch 'origin/issue-336' into issue-336
sravanmedarapu 7a4b6ec
Added unit tests and fixed tilde replace regex.
sravanmedarapu aacf6bd
Merge branch 'master' into issue-336
bootstraponline 6211c0f
Fix tests
bootstraponline 3dd27d4
Fix single glob splitting
bootstraponline 2eefeee
Update release notes
bootstraponline 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 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 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 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package ftl.args | ||
|
||
import ftl.util.Utils.fatalError | ||
import java.io.IOException | ||
import java.nio.file.FileSystems | ||
import java.nio.file.FileVisitOption | ||
import java.nio.file.FileVisitResult | ||
import java.nio.file.Files | ||
import java.nio.file.LinkOption | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import java.nio.file.SimpleFileVisitor | ||
import java.nio.file.attribute.BasicFileAttributes | ||
import java.util.EnumSet | ||
|
||
class ArgsFileVisitor(glob: String) : SimpleFileVisitor<Path>() { | ||
private val pathMatcher = FileSystems.getDefault().getPathMatcher(glob) | ||
private val result: MutableList<Path> = mutableListOf() | ||
|
||
@Throws(IOException::class) | ||
override fun visitFile(path: Path, attrs: BasicFileAttributes): FileVisitResult { | ||
if (pathMatcher.matches(path)) { | ||
result.add(path) | ||
} | ||
return FileVisitResult.CONTINUE | ||
} | ||
|
||
override fun visitFileFailed(file: Path?, exc: IOException?): FileVisitResult { | ||
fatalError("Failed to visit $file $exc") | ||
return FileVisitResult.CONTINUE | ||
} | ||
|
||
companion object { | ||
private const val RECURSE = "/**" | ||
private const val SINGLE_GLOB = "/*" | ||
} | ||
|
||
@Throws(java.nio.file.NoSuchFileException::class) | ||
fun walk(searchPath: Path): List<Path> { | ||
val searchString = searchPath.toString() | ||
// /Users/tmp/code/flank/test_app/** => /Users/tmp/code/flank/test_app/ | ||
// /Users/tmp/code/* => /Users/tmp/code/ | ||
val beforeGlob = Paths.get(searchString.substringBefore(SINGLE_GLOB)) | ||
// must not follow links when resolving paths or /tmp turns into /private/tmp | ||
val realPath = beforeGlob.toRealPath(LinkOption.NOFOLLOW_LINKS) | ||
val searchDepth = if (searchString.contains(RECURSE)) Integer.MAX_VALUE else 1 | ||
|
||
Files.walkFileTree(realPath, EnumSet.of(FileVisitOption.FOLLOW_LINKS), searchDepth, this) | ||
return this.result | ||
} | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.
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.
I would prefer if we also printed this value to console. Something like -
Resolved app file path - "$file"
.Under a conditional.
if (filePath != file)
.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.
I think it should be printed already when the args are printed to stdout at the start of a test run.