Skip to content

Commit 4a4d181

Browse files
chore: extract manifest file location to function
1 parent 1cd5b16 commit 4a4d181

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/kotlin/net/leanix/githubagent/services/WebhookEventService.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ class WebhookEventService(
108108
manifestFilePath: String,
109109
action: ManifestFileAction
110110
) {
111-
val location = if ('/' in manifestFilePath) {
112-
"directory '/${manifestFilePath.substringBeforeLast('/')}'"
113-
} else {
114-
"root folder"
115-
}
111+
val location = getManifestFileLocation(manifestFilePath)
116112

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

@@ -134,11 +130,7 @@ class WebhookEventService(
134130
}
135131

136132
private fun handleRemovedManifestFile(repositoryFullName: String, manifestFilePath: String) {
137-
val location = if ('/' in manifestFilePath) {
138-
"directory '/${manifestFilePath.substringBeforeLast('/')}'"
139-
} else {
140-
"root folder"
141-
}
133+
val location = getManifestFileLocation(manifestFilePath)
142134
logger.info("Manifest file ${ManifestFileAction.REMOVED} from repository $repositoryFullName under $location")
143135
webSocketService.sendMessage(
144136
"/events/manifestFile",
@@ -150,4 +142,12 @@ class WebhookEventService(
150142
)
151143
)
152144
}
145+
146+
private fun getManifestFileLocation(manifestFilePath: String): String {
147+
return if (manifestFilePath.contains('/')) {
148+
"directory '/${manifestFilePath.substringBeforeLast('/')}'"
149+
} else {
150+
"root folder"
151+
}
152+
}
153153
}

0 commit comments

Comments
 (0)