Nullable git tag messages
ci/woodpecker/push/pages Pipeline was successful Details
ci/woodpecker/push/gradle Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2022-11-25 17:12:33 +01:00
parent 81aebec2c6
commit b545835010
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 5 additions and 3 deletions

View File

@ -33,7 +33,7 @@ fun Ref.resolveTag(repo: Repository): Tag = RevWalk(repo).use { walk ->
// Lightweight (unannotated) tag
// Copy information from commit
val target = walk.parseCommit(objectId).resolve(repo)
return Tag(objectId, null, name, target, target.author, target.fullMessage, target.shortMessage, target.dateTime)
return Tag(objectId, null, name, target, target.author, null, null, target.dateTime)
}
walk.parseBody(rev)
walk.parseBody(rev.`object`)
@ -50,8 +50,8 @@ fun RevTag.resolve(commit: Commit): Tag {
name,
commit,
Person(ident, ident.name, ident.emailAddress),
fullMessage,
shortMessage,
fullMessage.nullable,
shortMessage.nullable,
ZonedDateTime.ofInstant(
ident.`when`.toInstant(),
ident.timeZone?.toZoneId() ?: ZoneOffset.UTC
@ -79,6 +79,8 @@ fun RevCommit.resolve(repo: Repository): Commit = Commit(
parents.map { ObjectId.toString(it) }
)
private val String?.nullable get() = if (this == null || this == "") null else this
data class Tag(val id: ObjectId, val original: RevTag?, val fullName: String, val commit: Commit?, val tagger: Person?, val fullMessage: String?, val shortMessage: String?, val dateTime: ZonedDateTime?) {
val name: String
get() = Repository.shortenRefName(fullName)