-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'xpdustry:master' into christmas-event
- Loading branch information
Showing
11 changed files
with
172 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
imperium-build-logic/src/main/kotlin/GenerateImperiumChangelog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import java.util.regex.Pattern | ||
import net.kyori.indra.git.IndraGitExtension | ||
import org.eclipse.jgit.lib.Constants | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.file.RegularFileProperty | ||
import org.gradle.api.tasks.CacheableTask | ||
import org.gradle.api.tasks.OutputFile | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
@CacheableTask | ||
open class GenerateImperiumChangelog : DefaultTask() { | ||
|
||
@OutputFile | ||
val target: RegularFileProperty = project.objects.fileProperty() | ||
|
||
@TaskAction | ||
fun generate() { | ||
val git = project.rootProject.extensions.getByType<IndraGitExtension>().git()!! | ||
val latest = git.repository.resolve("v" + project.rootProject.file("VERSION.txt").readText().trim())!! | ||
val head = git.repository.resolve(Constants.HEAD)!! | ||
target.get().asFile.writer().buffered().use { writer -> | ||
git.log().addRange(latest, head).call().forEach { commit -> | ||
val message = commit.shortMessage ?: return@forEach | ||
val matcher = ACCEPTED_SUFFIX.matcher(message) | ||
if (!matcher.find()) return@forEach | ||
writer.write(matcher.group("verb").lowercase()) | ||
writer.write("/") | ||
writer.write(matcher.group("scope")?.lowercase() ?: "common") | ||
writer.write("/") | ||
writer.write(message.split(':', limit = 2)[1].trim()) | ||
writer.newLine() | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
private val ACCEPTED_SUFFIX = Pattern.compile("^(?<verb>feat|fix)(\\((?<scope>mindustry|discord)\\))?:", Pattern.CASE_INSENSITIVE) | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
imperium-build-logic/src/main/kotlin/imperium.parent-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
imperium-mindustry/src/main/kotlin/com/xpdustry/imperium/mindustry/game/ChangelogCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* Imperium, the software collection powering the Chaotic Neutral network. | ||
* Copyright (C) 2024 Xpdustry | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package com.xpdustry.imperium.mindustry.game | ||
|
||
import com.xpdustry.distributor.api.command.CommandSender | ||
import com.xpdustry.distributor.api.component.Component | ||
import com.xpdustry.distributor.api.component.ListComponent.components | ||
import com.xpdustry.distributor.api.component.TextComponent.newline | ||
import com.xpdustry.distributor.api.component.TextComponent.text | ||
import com.xpdustry.distributor.api.component.style.ComponentColor | ||
import com.xpdustry.imperium.common.application.ImperiumApplication | ||
import com.xpdustry.imperium.common.command.ImperiumCommand | ||
import com.xpdustry.imperium.mindustry.command.annotation.ClientSide | ||
import com.xpdustry.imperium.mindustry.command.annotation.ServerSide | ||
import com.xpdustry.imperium.mindustry.translation.GRAY | ||
import java.io.Reader | ||
|
||
class ChangelogCommand : ImperiumApplication.Listener { | ||
|
||
private val changelog: Component | ||
|
||
init { | ||
val features = ArrayList<String>() | ||
val bugfixes = ArrayList<String>() | ||
javaClass.classLoader | ||
.getResourceAsStream("imperium-changelog.txt")!! | ||
.reader() | ||
.use(Reader::readLines) | ||
.forEach { entry -> | ||
val (verb, scope, message) = entry.split('/', limit = 3) | ||
if (scope == "common" || scope == "mindustry") { | ||
when (verb) { | ||
"feat" -> features += message | ||
"fix" -> bugfixes += message | ||
} | ||
} | ||
} | ||
|
||
val builder = components() | ||
val none = text("None", GRAY) | ||
builder.append(newline()) | ||
builder.append(text("Features and Changes", ComponentColor.ACCENT)) | ||
builder.append(newline()) | ||
if (features.isNotEmpty()) { | ||
features.forEach { feature -> builder.append(text(" - "), text(feature), newline()) } | ||
} else { | ||
builder.append(none) | ||
} | ||
builder.append(text("Bugfixes", ComponentColor.ACCENT)) | ||
builder.append(newline()) | ||
if (bugfixes.isNotEmpty()) { | ||
bugfixes.forEach { fix -> builder.append(text(" - "), text(fix), newline()) } | ||
} else { | ||
builder.append(none) | ||
} | ||
changelog = builder.build() | ||
} | ||
|
||
@ImperiumCommand(["changelog"]) | ||
@ClientSide | ||
@ServerSide | ||
fun onChangelogCommand(sender: CommandSender) { | ||
if (sender.isPlayer) { | ||
sender.audience.sendAnnouncement(changelog) | ||
} else { | ||
sender.audience.sendMessage(changelog) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters