-
Notifications
You must be signed in to change notification settings - Fork 92
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
I'd like an AddCommand.addFilePatterns method that takes a Collection<String>, and calls AddCommand.addFilePattern on each member of the collection.
Motivation
I have (Kotlin) code using JGit to add files. The call site looks like this:
git.add()
.setUpdate(false)
.addFilepattern("CHANGELOG.md")
.addFilepattern("app/build.gradle.kts")
.call()Now I need to amend this to add multiple files, where the list of files to add is returned by another function. Currently this is awkward, and becomes something like:
val patternsToAdd = myfunc()
val addCommand = git.add()
.setUpdate(false)
.addFilepattern("CHANGELOG.md")
.addFilepattern("app/build.gradle.kts")
patternsToAdd.forEach { addCommand.addFilePattern(it) }
addCommand.call()I'd prefer this:
git.add()
.setUpdate(false)
.addFilepattern("CHANGELOG.md")
.addFilepattern("app/build.gradle.kts")
.addFilePatterns(myfunc())
.call()Handily, in Kotlin I can do this with an extension function like this:
fun AddCommand.addFilePatterns(patterns: Collection<String>): AddCommand {
patterns.forEach { addFilepattern(it) }
return this
}But this seems useful enough it should be part of the API.
Alternatives considered
No response
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request