Skip to content

Commit

Permalink
chore: extract manifest file location to function
Browse files Browse the repository at this point in the history
  • Loading branch information
kostas-petrakis committed Nov 5, 2024
1 parent 1cd5b16 commit 4a4d181
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,7 @@ class WebhookEventService(
manifestFilePath: String,
action: ManifestFileAction
) {
val location = if ('/' in manifestFilePath) {
"directory '/${manifestFilePath.substringBeforeLast('/')}'"
} else {
"root folder"
}
val location = getManifestFileLocation(manifestFilePath)

logger.info("Manifest file {} in repository {} under {}", action, repositoryFullName, location)

Expand All @@ -134,11 +130,7 @@ class WebhookEventService(
}

private fun handleRemovedManifestFile(repositoryFullName: String, manifestFilePath: String) {
val location = if ('/' in manifestFilePath) {
"directory '/${manifestFilePath.substringBeforeLast('/')}'"
} else {
"root folder"
}
val location = getManifestFileLocation(manifestFilePath)
logger.info("Manifest file ${ManifestFileAction.REMOVED} from repository $repositoryFullName under $location")
webSocketService.sendMessage(
"/events/manifestFile",
Expand All @@ -150,4 +142,12 @@ class WebhookEventService(
)
)
}

private fun getManifestFileLocation(manifestFilePath: String): String {
return if (manifestFilePath.contains('/')) {
"directory '/${manifestFilePath.substringBeforeLast('/')}'"
} else {
"root folder"
}
}
}

0 comments on commit 4a4d181

Please sign in to comment.