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".
This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Gleb Koval dbc1bdd105
Test Workflow / Lint and test library (push) Successful in 1m51s Details
Publish Workflow / Publish library (push) Successful in 2m18s Details
Branch support (#7)
Closes #6.

Implements branch support by _only extending_ the existing functionality. Note that the existing functionality DOES NOT implement a `parent` pointer for commits, and as a result branches are also implemented differently to how git implements them.

git branches are simply a named pointer to a commit object (which then has a pointer to its parent commit), here branches store the entire sequence of pointers to commit objects.

### Why different to git?
I made a mistake in the initial implementation by using a `TreeSet` instead of manually implementing a tree for commits. This allowed the ability to insert commits in-between other commits, which isn't normally possible in `git` _without rebasing which changes commits' hashes_.

The specification for this feature stated:
> All functionality that is implemented already should be preserved.

And so since I cannot remove this functionality any more, I have to build on top of it.

Reviewed-on: #7
2024-01-10 12:21:25 +00:00
.github/workflows Initial publish (#2) 2023-12-02 01:00:03 +00:00
.idea Initial library implementations and tests (#1) 2023-12-01 20:42:07 +00:00
gradle/wrapper Initial commit 2023-11-30 23:46:20 +00:00
src Branch support (#7) 2024-01-10 12:21:25 +00:00
.editorconfig Initial commit 2023-11-30 23:46:20 +00:00
.gitignore Initial commit 2023-11-30 23:46:20 +00:00
README.md Cleanup and privatise commit comparator 2023-12-05 02:00:35 +00:00
build.gradle.kts Documentation generation (Dokka HTML) (#3) 2023-12-02 02:05:55 +00:00
gradle.properties Initial commit 2023-11-30 23:46:20 +00:00
gradlew Initial commit 2023-11-30 23:46:20 +00:00
gradlew.bat Initial commit 2023-11-30 23:46:20 +00:00
settings.gradle.kts Initial commit 2023-11-30 23:46:20 +00:00

README.md

TeamCity support for Gitea - Test Task

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".

The package is named tinyvm for 'tiny version manager'.

Assumptions

Since this is an internship application project, I have assumed that a minimal usage of external libraries is preferred, so that a greater technical understanding can be demonstrated.

Usage

Gradle

repositories {
    // other repositories
    maven { url "https://git.koval.net/api/packages/cyclane/maven" }
}

dependencies {
    // other dependencies
    implementation("net.koval.teamcity-gitea-test-task:tinyvm:0.1.1")
}

Documentation

Use autocompletion and hover menus in your IDE, or download the generated HTML documentation from the latest release.

Instructions

Create a library that implements simple Git functionality. You need to implement at least three entities:

  • Blob will contain some data, which for the sake of simplicity, will be represented as a string. Additionally, it will store a SHA-1 hash* that uniquely identifies the blob;
  • Tree will function as a container for a collection of named blobs or other trees. It will also have a SHA-1 hash that uniquely identifies the tree;
  • Commit will serve as a pointer to the main Tree object and store metadata related to the commit. This metadata will include the author of the commit, the commit message, the commit time, and the SHA-1 hash of the commit itself. Commits should be stored chronologically so that their relationship can be tracked.

Your implementation should avoid stored data redundancy like real Git does. The implementation does not need to include persistence functionality, which refers to the ability to store data using the library in previous runs.

The library you implement should be able to:

  • Create new commits;
  • List commits;
  • Search for specific commit by hash or metadata and print its content.

You should use Java or Kotlin for your implementation. It would be highly beneficial to implement tests for basic usage scenarios and corner cases.

*SHA-1 hash is a cryptographic hash function that calculates a unique fixed-size output based on the input data