Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class AutoCompleteCommand(
val pipelines = gitProvider.getAllPipelines()

outputHandler.listPipelines(
pipelines.filter { it.matches(word) }
pipelines
.filter { it.matches(word) }
.sortedWith(compareBy({ it.container }, { it.name })),
)
}
Expand All @@ -61,7 +62,8 @@ class AutoCompleteCommand(
val pipelineRuns = gitProvider.getPipelineRuns(pipelineId)

outputHandler.listPipelineRuns(
pipelineRuns.filter { it.matches(word) }
pipelineRuns
.filter { it.matches(word) }
.sortedByDescending { it.createdDate }
.take(TOP_20_PIPELINES),
)
Expand Down Expand Up @@ -90,7 +92,8 @@ class AutoCompleteCommand(

repository?.let { repo ->
outputHandler.listBranches(
gitProvider.getAllRefs(repo, "heads/")
gitProvider
.getAllRefs(repo, "heads/")
.filter { word == null || intelliSearch.matches(word, it.shortName) },
)
} ?: outputHandler.error("No repository could be determined")
Expand Down Expand Up @@ -137,8 +140,11 @@ class AutoCompleteCommand(
intelliSearch.matches(value, uniqueName)

private fun PipelineRun.matches(word: String?) =
word == null || intelliSearch.matches(word, id.toString()) || intelliSearch.matches(word, name) ||
intelliSearch.matches(word, state.toString()) || intelliSearch.matches(word, result.toString())
word == null ||
intelliSearch.matches(word, id.toString()) ||
intelliSearch.matches(word, name) ||
intelliSearch.matches(word, state.toString()) ||
intelliSearch.matches(word, result.toString())

private fun getPipelineByUniqueName(pipelineIdFlag: String) =
requireNotNull(gitProvider.getAllPipelines().firstOrNull { it.uniqueName == pipelineIdFlag }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ class PullRequestCreateCommand(
"PR created by RET using `ret pr create --no-prompt`.",
)
val pullRequestUrl =
gitProvider.urlFactory.pullRequest(
repositoryName,
createPullRequestResponse.pullRequestId,
).toString()
gitProvider.urlFactory
.pullRequest(
repositoryName,
createPullRequestResponse.pullRequestId,
).toString()
outputHandler.println(pullRequestUrl)
} catch (e: ClientWebApplicationException) {
val message =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CommandLineConfiguration {
factory: PicocliCommandLineFactory,
outputHandler: OutputHandler,
): CommandLine =
factory.create()
factory
.create()
.setExecutionExceptionHandler(ExceptionMessageHandler(outputHandler))
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import io.quarkus.logging.Log
import io.rabobank.ret.git.plugin.output.OutputHandler
import picocli.CommandLine

class ExceptionMessageHandler(private val outputHandler: OutputHandler) : CommandLine.IExecutionExceptionHandler {
class ExceptionMessageHandler(
private val outputHandler: OutputHandler,
) : CommandLine.IExecutionExceptionHandler {
override fun handleExecutionException(
exception: Exception,
commandLine: CommandLine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import io.rabobank.ret.git.plugin.provider.PipelineRunState
import io.rabobank.ret.git.plugin.provider.PullRequest
import io.rabobank.ret.git.plugin.provider.Repository

class AlfredAutocompleteHandler(private val retConsole: RetConsole, private val objectMapper: ObjectMapper) :
OutputHandler {
override fun println(message: String) {
throw UnsupportedOperationException()
}
class AlfredAutocompleteHandler(
private val retConsole: RetConsole,
private val objectMapper: ObjectMapper,
) : OutputHandler {
override fun println(message: String): Unit = throw UnsupportedOperationException()

override fun error(message: String) {
throw UnsupportedOperationException()
}
override fun error(message: String): Unit = throw UnsupportedOperationException()

override fun listPRs(list: List<PullRequest>) {
retConsole.out(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import io.rabobank.ret.git.plugin.provider.PullRequest
import io.rabobank.ret.git.plugin.provider.Repository

@RegisterForReflection
data class Wrapper(val items: List<Item>)
data class Wrapper(
val items: List<Item>,
)

@RegisterForReflection
data class ItemIcon(val path: String)
data class ItemIcon(
val path: String,
)

@RegisterForReflection
data class Item(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import io.rabobank.ret.git.plugin.provider.PipelineRun
import io.rabobank.ret.git.plugin.provider.PullRequest
import io.rabobank.ret.git.plugin.provider.Repository

class AlfredOutputHandler(private val retConsole: RetConsole, private val objectMapper: ObjectMapper) : OutputHandler {
override fun listPRs(list: List<PullRequest>) {
throw UnsupportedOperationException()
}
class AlfredOutputHandler(
private val retConsole: RetConsole,
private val objectMapper: ObjectMapper,
) : OutputHandler {
override fun listPRs(list: List<PullRequest>): Unit = throw UnsupportedOperationException()

override fun error(message: String) {
retConsole.out(objectMapper.writeValueAsString(Wrapper(listOf(Item("Error: $message", false)))))
Expand All @@ -21,19 +22,11 @@ class AlfredOutputHandler(private val retConsole: RetConsole, private val object
retConsole.out(objectMapper.writeValueAsString(Wrapper(listOf(Item(message)))))
}

override fun listRepositories(list: List<Repository>) {
throw UnsupportedOperationException()
}
override fun listRepositories(list: List<Repository>): Unit = throw UnsupportedOperationException()

override fun listBranches(list: List<Branch>) {
throw UnsupportedOperationException()
}
override fun listBranches(list: List<Branch>): Unit = throw UnsupportedOperationException()

override fun listPipelines(list: List<Pipeline>) {
throw UnsupportedOperationException()
}
override fun listPipelines(list: List<Pipeline>): Unit = throw UnsupportedOperationException()

override fun listPipelineRuns(list: List<PipelineRun>) {
throw UnsupportedOperationException()
}
override fun listPipelineRuns(list: List<PipelineRun>): Unit = throw UnsupportedOperationException()
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import io.rabobank.ret.git.plugin.provider.PipelineRunState
import io.rabobank.ret.git.plugin.provider.PullRequest
import io.rabobank.ret.git.plugin.provider.Repository

class CliAutocompleteHandler(private val retConsole: RetConsole) : OutputHandler {
class CliAutocompleteHandler(
private val retConsole: RetConsole,
) : OutputHandler {
override fun listPRs(list: List<PullRequest>) {
list.map { "${it.id}:${it.repository.name}: ${it.title}" }.forEach(retConsole::out)
}
Expand All @@ -26,9 +28,10 @@ class CliAutocompleteHandler(private val retConsole: RetConsole) : OutputHandler
}

override fun listPipelineRuns(list: List<PipelineRun>) {
list.map {
val combinedState = if (it.state == PipelineRunState.COMPLETED) it.result else it.state
"${it.id}:${it.name} ($combinedState)"
}.forEach(retConsole::out)
list
.map {
val combinedState = if (it.state == PipelineRunState.COMPLETED) it.result else it.state
"${it.id}:${it.name} ($combinedState)"
}.forEach(retConsole::out)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import io.rabobank.ret.git.plugin.provider.PipelineRun
import io.rabobank.ret.git.plugin.provider.PullRequest
import io.rabobank.ret.git.plugin.provider.Repository

class CliOutputHandler(private val retConsole: RetConsole) : OutputHandler {
class CliOutputHandler(
private val retConsole: RetConsole,
) : OutputHandler {
override fun println(message: String) {
retConsole.out(message)
}
Expand All @@ -16,23 +18,13 @@ class CliOutputHandler(private val retConsole: RetConsole) : OutputHandler {
retConsole.errorOut(message)
}

override fun listPRs(list: List<PullRequest>) {
throw UnsupportedOperationException()
}
override fun listPRs(list: List<PullRequest>): Unit = throw UnsupportedOperationException()

override fun listRepositories(list: List<Repository>) {
throw UnsupportedOperationException()
}
override fun listRepositories(list: List<Repository>): Unit = throw UnsupportedOperationException()

override fun listBranches(list: List<Branch>) {
throw UnsupportedOperationException()
}
override fun listBranches(list: List<Branch>): Unit = throw UnsupportedOperationException()

override fun listPipelines(list: List<Pipeline>) {
throw UnsupportedOperationException()
}
override fun listPipelines(list: List<Pipeline>): Unit = throw UnsupportedOperationException()

override fun listPipelineRuns(list: List<PipelineRun>) {
throw UnsupportedOperationException()
}
override fun listPipelineRuns(list: List<PipelineRun>): Unit = throw UnsupportedOperationException()
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ data class PullRequestCreated(
val pullRequestId: String,
) : GitDomain

data class Reviewer(val uniqueName: String) : GitDomain
data class Reviewer(
val uniqueName: String,
) : GitDomain

data class Repository(
val name: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import org.eclipse.microprofile.rest.client.ext.ClientHeadersFactory
import java.util.Base64

@Singleton
class AuthorizationHeaderInjector(private val pluginConfig: AzureDevopsPluginConfig) : ClientHeadersFactory {
class AuthorizationHeaderInjector(
private val pluginConfig: AzureDevopsPluginConfig,
) : ClientHeadersFactory {
override fun update(
incomingHeaders: MultivaluedMap<String, String>,
outgoingHeaders: MultivaluedMap<String, String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ class AzureDevopsConfiguration(
) {
@Produces
fun azureDevopsRestClient(): AzureDevopsClient =
RestClientBuilder.newBuilder()
RestClientBuilder
.newBuilder()
.baseUrl(
UriBuilder.fromUri(URI.create(azureDevopsBaseUrl))
UriBuilder
.fromUri(URI.create(azureDevopsBaseUrl))
.path(pluginConfig.config.organization)
.path(pluginConfig.config.project)
.path("_apis")
.build()
.toURL(),
)
.build(AzureDevopsClient::class.java)
).build(AzureDevopsClient::class.java)
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ class AzureDevopsUrlFactory(
if (sourceRef != null) {
queryParam("sourceRef", sourceRef)
}
}
.buildToURL()
}.buildToURL()

private fun azdoBaseUriBuilder() =
UriBuilder.fromUri(azureDevopsBaseUrl)
UriBuilder
.fromUri(azureDevopsBaseUrl)
.path(pluginConfig.config.organization)
.path(pluginConfig.config.project)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ data class PipelineRun(
)
}

enum class PipelineRunState(private val genericEquivalent: GenericPipelineRunState) :
GitDomainConvertible<GenericPipelineRunState> {
enum class PipelineRunState(
private val genericEquivalent: GenericPipelineRunState,
) : GitDomainConvertible<GenericPipelineRunState> {
@JsonProperty("canceling")
CANCELING(GenericPipelineRunState.CANCELING),

Expand All @@ -124,8 +125,9 @@ enum class PipelineRunState(private val genericEquivalent: GenericPipelineRunSta
override fun toGenericDomain() = genericEquivalent
}

enum class PipelineRunResult(private val genericEquivalent: GenericPipelineRunResult) :
GitDomainConvertible<GenericPipelineRunResult> {
enum class PipelineRunResult(
private val genericEquivalent: GenericPipelineRunResult,
) : GitDomainConvertible<GenericPipelineRunResult> {
@JsonProperty("canceled")
CANCELED(GenericPipelineRunResult.CANCELED),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ class AutoCompleteCommandTest {
Pipeline(1, "admin-service deployment", "blabla", "blabla\\admin-service deployment"),
Pipeline(2, "blabla", "admin-service", "admin-service\\blabla"),
),
) && !this.contains(Pipeline(3, "blabla", "blabla", "blabla\\blabla"))
) &&
!this.contains(Pipeline(3, "blabla", "blabla", "blabla\\blabla"))
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class AzureDevopsPluginConfigLoadTest {
"azure_devops_organization" to "my-organization",
)
pluginConfig.objectMapper.writeValue(
pluginConfig.osUtils.getRetPluginsDirectory().resolve(pluginConfigFileName).toFile(),
pluginConfig.osUtils
.getRetPluginsDirectory()
.resolve(pluginConfigFileName)
.toFile(),
config,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import io.rabobank.ret.git.plugin.provider.GitUrlFactory
import jakarta.ws.rs.core.UriBuilder
import java.net.URL

class TestUrlFactory(private val domain: String) : GitUrlFactory {
class TestUrlFactory(
private val domain: String,
) : GitUrlFactory {
override fun repository(repositoryName: String) = "$domain/repository/$repositoryName".toURL()

override fun pipelineRun(pipelineRunId: String) = "$domain/pipeline/run/$pipelineRunId".toURL()
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
<mockito-inline.version>5.2.0</mockito-inline.version>
<mockito-kotlin.version>6.0.0</mockito-kotlin.version>
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
<quarkus.platform.version>3.26.1</quarkus.platform.version>
<quarkus.platform.version>3.26.2</quarkus.platform.version>
<ret-plugin.version>0.2.4</ret-plugin.version>
<skipITs>true</skipITs>
<surefire-plugin.version>3.5.3</surefire-plugin.version>
<versions-maven-plugin.version>2.18.0</versions-maven-plugin.version>
<versions-maven-plugin.version>2.19.0</versions-maven-plugin.version>
</properties>

<modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class SplunkCommand(
val query = queryArguments.filterNotNull().joinToString(" ")

val url =
UriBuilder.fromUri(splunkUrl)
UriBuilder
.fromUri(splunkUrl)
.apply {
if (query.isNotBlank()) {
queryParam("q", "search $query")
}
}
.build()
}.build()
.toASCIIString()

Log.info("Querying splunk with url '$url'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package io.rabobank.ret.splunk.plugin.output
import com.fasterxml.jackson.databind.ObjectMapper
import io.rabobank.ret.RetConsole

class AlfredAutocompleteHandler(private val retConsole: RetConsole, private val objectMapper: ObjectMapper) :
OutputHandler {
override fun println(message: String) {
throw UnsupportedOperationException()
}
class AlfredAutocompleteHandler(
private val retConsole: RetConsole,
private val objectMapper: ObjectMapper,
) : OutputHandler {
override fun println(message: String): Unit = throw UnsupportedOperationException()

override fun error(message: String) {
throw UnsupportedOperationException()
}
override fun error(message: String): Unit = throw UnsupportedOperationException()

override fun listIndexes(indexes: List<String>) {
retConsole.out(
Expand Down
Loading