CtrlK
BlogDocsLog inGet started
Tessl Logo

finkel/jgit

JGit documentation and API reference with code examples

92

1.09x
Quality

Pending

Does it follow best practices?

Impact

92%

1.09x

Average score across 10 eval scenarios

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

task.mdevals/scenario-1/

Git Repository Setup Utility

Problem/Feature Description

Our development team maintains a project scaffolding tool that creates starter projects for various frameworks (Spring Boot, React, etc.). Currently, the Git repository initialization is done through shell commands, which causes issues on Windows environments and makes error handling difficult.

We need a Java utility class that can reliably initialize Git repositories, add initial files, and make the first commit. The utility should be used by our scaffolding engine running in a CI/CD environment where multiple projects are created simultaneously.

The main requirements:

  • Initialize a new Git repository at a specified path (non-bare, with working tree)
  • Add a set of starter files to the repository
  • Create an initial commit with a configurable message
  • Handle errors gracefully (e.g., directory permissions, existing .git folder)
  • Ensure resources are properly cleaned up even if operations fail
  • Support both programmatic usage and command-line invocation

Output Specification

Create a Java class GitRepositoryInitializer that provides the following functionality:

  1. Constructor: Takes a base directory path where the repository should be created
  2. initializeRepository(): Creates the repository directory if needed, initializes Git repository
  3. addFiles(List<Path> files): Adds specified files to the repository (files will exist in the directory)
  4. commit(String message): Creates initial commit with the given message
  5. close(): Cleans up any resources (if not using try-with-resources pattern)

The class should be production-ready with proper error handling and resource management. Include a simple main method demonstrating usage.

Expected output files:

  • GitRepositoryInitializer.java - The main utility class
  • README.md - Brief documentation on how to use the class
  • pom.xml or build.gradle - Build configuration with JGit dependency

The solution should be self-contained and include any necessary imports. Assume Java 11 or higher.

tile.json