Compare commits
2 Commits
11e0b03904
...
v0.0.2
Author | SHA1 | Date | |
---|---|---|---|
14950b2f5f | |||
6d8c6008e1 |
40
.github/workflows/publish.yaml
vendored
Normal file
40
.github/workflows/publish.yaml
vendored
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
name: Publish Workflow
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish library
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Java
|
||||||
|
uses: actions/setup-java@v3
|
||||||
|
with:
|
||||||
|
distribution: adopt
|
||||||
|
java-version: 17
|
||||||
|
|
||||||
|
- name: Verify Gradle wrapper
|
||||||
|
uses: gradle/wrapper-validation-action@v1
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/gradle-build-action@v2
|
||||||
|
|
||||||
|
- name: Run checks
|
||||||
|
run: ./gradlew check
|
||||||
|
|
||||||
|
- name: Parse parameters
|
||||||
|
id: parse
|
||||||
|
run: |
|
||||||
|
export VERSION="$(echo ${{ github.ref_name }} | cut -c2-)"
|
||||||
|
echo "Parsed version: '$VERSION'"
|
||||||
|
echo "tinyvm_version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Publish to Gitea package repository
|
||||||
|
env:
|
||||||
|
TINYVM_VERSION: ${{ steps.parse.outputs.tinyvm_version }}
|
||||||
|
GITEA_USERNAME: ${{ github.repository_owner }}
|
||||||
|
GITEA_TOKEN: ${{ secrets.deploy_token }}
|
||||||
|
run: ./gradlew publishAllPublicationsToGiteaRepository
|
@@ -1,4 +1,4 @@
|
|||||||
name: Main Workflow
|
name: Test Workflow
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
@@ -16,7 +16,7 @@ jobs:
|
|||||||
- name: Set up Java
|
- name: Set up Java
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: adopt
|
||||||
java-version: 17
|
java-version: 17
|
||||||
|
|
||||||
- name: Verify Gradle wrapper
|
- name: Verify Gradle wrapper
|
@@ -1,10 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "1.9.21"
|
kotlin("jvm") version "1.9.21"
|
||||||
id("org.jmailen.kotlinter") version "4.1.0"
|
id("org.jmailen.kotlinter") version "4.1.0"
|
||||||
|
id("org.jetbrains.dokka") version "1.9.10"
|
||||||
|
`maven-publish`
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "net.koval"
|
group = "net.koval.teamcity-gitea-test-task"
|
||||||
version = "1.0-SNAPSHOT"
|
version = System.getenv("TINYVM_VERSION")
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -20,4 +22,47 @@ tasks.test {
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
jvmToolchain(17)
|
jvmToolchain(17)
|
||||||
|
}
|
||||||
|
|
||||||
|
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
|
||||||
|
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
|
||||||
|
dependsOn(dokkaHtml)
|
||||||
|
archiveClassifier.set("javadoc")
|
||||||
|
from(dokkaHtml.outputDirectory)
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications.register<MavenPublication>("gpr") {
|
||||||
|
artifactId = "tinyvm"
|
||||||
|
from(components["java"])
|
||||||
|
artifact(javadocJar)
|
||||||
|
pom {
|
||||||
|
name.set("TeamCity support for Gitea - Test Task - tiny version manager")
|
||||||
|
description.set("This is a small project to implement a subset of git's functionality in Kotlin and was " +
|
||||||
|
"created using the instructions below as part of my application to the JetBrains internship project " +
|
||||||
|
"\"TeamCity support for Gitea\".")
|
||||||
|
url.set("https://git.koval.net/cyclane/teamcity-gitea-test-task")
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id.set("cyclane")
|
||||||
|
name.set("Gleb Koval")
|
||||||
|
email.set("gleb@koval.net")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
url.set("https://git.koval.net/cyclane/teamcity-gitea-test-task")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "Gitea"
|
||||||
|
url = uri("https://git.koval.net/api/packages/cyclane/maven")
|
||||||
|
credentials {
|
||||||
|
username = System.getenv("GITEA_USERNAME")
|
||||||
|
password = System.getenv("GITEA_TOKEN")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@@ -2,28 +2,36 @@ package tinyvm
|
|||||||
|
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
import java.util.HexFormat
|
||||||
|
|
||||||
abstract class Object(
|
/**
|
||||||
val type: String,
|
* Represents an arbitrary version manager object.
|
||||||
) {
|
*/
|
||||||
|
abstract class Object(val type: String) {
|
||||||
abstract val data: String
|
abstract val data: String
|
||||||
|
|
||||||
fun hash(): String =
|
fun hash(): String =
|
||||||
MessageDigest
|
HexFormat.of().formatHex(
|
||||||
.getInstance("SHA-1")
|
MessageDigest
|
||||||
.digest("$type ${data.length}\u0000$data".toByteArray())
|
.getInstance("SHA-1")
|
||||||
.toHex()
|
.digest("$type ${data.length}\u0000$data".toByteArray()),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commits are a pointer to a 'head' tree with some metadata.
|
||||||
|
*/
|
||||||
class Commit(
|
class Commit(
|
||||||
val tree: Tree,
|
val tree: Tree,
|
||||||
val author: Author,
|
val author: Author,
|
||||||
val message: String,
|
val message: String,
|
||||||
val timestamp: Instant,
|
val timestamp: Instant,
|
||||||
) : Object("commit") {
|
) : Object("commit") {
|
||||||
// Use \n\n for end of header in-case additional metadata is implemented in the future.
|
|
||||||
override val data: String
|
override val data: String
|
||||||
|
// Use \n\n for end of header in-case additional metadata is implemented in the future.
|
||||||
get() = "tree ${tree.hash()}\nauthor $author\ntimestamp ${timestamp.epochSecond}\n\n$message"
|
get() = "tree ${tree.hash()}\nauthor $author\ntimestamp ${timestamp.epochSecond}\n\n$message"
|
||||||
|
|
||||||
|
override fun toString(): String = "commit ${hash()}\n$data"
|
||||||
}
|
}
|
||||||
|
|
||||||
data class Author(
|
data class Author(
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
package tinyvm
|
|
||||||
|
|
||||||
import java.util.HexFormat
|
|
||||||
|
|
||||||
fun ByteArray.toHex(): String = HexFormat.of().formatHex(this)
|
|
@@ -1,7 +1,13 @@
|
|||||||
package tinyvm
|
package tinyvm
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tree nodes are either trees or blobs, represented by this sealed class.
|
||||||
|
*/
|
||||||
sealed class Node(type: String) : Object(type)
|
sealed class Node(type: String) : Object(type)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A tree is a set of named nodes.
|
||||||
|
*/
|
||||||
class Tree(val nodes: Map<String, Node>) : Node("tree") {
|
class Tree(val nodes: Map<String, Node>) : Node("tree") {
|
||||||
// For simplicity just use the hex-formatted hash, not the actual value like git does.
|
// For simplicity just use the hex-formatted hash, not the actual value like git does.
|
||||||
override val data: String
|
override val data: String
|
||||||
@@ -11,4 +17,7 @@ class Tree(val nodes: Map<String, Node>) : Node("tree") {
|
|||||||
}.sorted().joinToString()
|
}.sorted().joinToString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A blob is a data container.
|
||||||
|
*/
|
||||||
class Blob(override val data: String) : Node("blob")
|
class Blob(override val data: String) : Node("blob")
|
Reference in New Issue
Block a user