All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.name.remal.gradle_plugins.plugins.vcs.Commit.kt Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version
package name.remal.gradle_plugins.plugins.vcs

import org.eclipse.jgit.revwalk.RevCommit
import java.time.Instant
import java.time.LocalDateTime
import java.time.ZoneId
import java.util.Date

data class Commit(
    val id: String,
    val localDateTime: LocalDateTime,
    val tags: List
) {

    val date: Date = Date.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant())

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (other == null || other !is Commit) return false
        return id == other.id
    }

    override fun hashCode() = id.hashCode()

}


fun RevCommit.toCommit(tags: List) = Commit(
    id = this.name,
    localDateTime = Instant.ofEpochSecond(this.commitTime.toLong()).atZone(ZoneId.systemDefault()).toLocalDateTime(),
    tags = tags
)




© 2015 - 2025 Weber Informatics LLC | Privacy Policy