Skip to content
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

Miscellaneous stuff / address some inspection hints #34

Merged
merged 2 commits into from
Sep 21, 2023
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 @@ -10,7 +10,7 @@ private const val MESSAGE = "Message"

class ChangeLogFormatter(private val settings: SemverSettings, private val format: ChangeLogSettings) {

private val changeLogRegex = format.changeLogPattern.toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE))
private val changeLogRegex = format.changeLogPattern.toRegex(SemverSettings.REGEX_OPTIONS)

internal fun formatLog(changeLog: List<Commit>): String {

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/git/semver/plugin/gradle/PrintTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open class PrintTask @Inject constructor(private val prop: () -> Any, desc: Stri

@TaskAction
fun print() {
val fileName = this.file;
val fileName = this.file
if (fileName != null) {
File(fileName).writeText(prop().toString(), StandardCharsets.UTF_8)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/git/semver/plugin/semver/SemVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,6 @@ class SemVersion(
val isPreRelease
get() = prefix.isNotEmpty() || number != null

override fun toString() = prefix + (number ?: "");
override fun toString() = prefix + (number ?: "")
}
}
11 changes: 7 additions & 4 deletions src/main/kotlin/git/semver/plugin/semver/SemverSettings.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package git.semver.plugin.semver

open class SemverSettings {
companion object {
val REGEX_OPTIONS = setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)
}

var defaultPreRelease = "SNAPSHOT"
var releasePattern = "\\Arelease(?:\\([^()]+\\))?:"
Expand All @@ -14,8 +17,8 @@ open class SemverSettings {
var noDirtyCheck = false
var noAutoBump = false

internal val releaseRegex: Regex by lazy { releasePattern.toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)) }
internal val patchRegex: Regex by lazy { patchPattern.toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)) }
internal val minorRegex: Regex by lazy { minorPattern.toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)) }
internal val majorRegex: Regex by lazy { majorPattern.toRegex(setOf(RegexOption.IGNORE_CASE, RegexOption.MULTILINE)) }
internal val releaseRegex: Regex by lazy { releasePattern.toRegex(REGEX_OPTIONS) }
internal val patchRegex: Regex by lazy { patchPattern.toRegex(REGEX_OPTIONS) }
internal val minorRegex: Regex by lazy { minorPattern.toRegex(REGEX_OPTIONS) }
internal val majorRegex: Regex by lazy { majorPattern.toRegex(REGEX_OPTIONS) }
}