Skip to content

Repository files navigation

Commmit Craft API

Craft

Requirements

  • Java 17+
  • Docker
  • Gradle (You can use Gradle Wrapper)

Quick Start

  1. Clone the repository:
    git clone <repository-URL>
    cd <repository-name>
  2. add your deepl api-key to translate/src/main/resources/application.yml in key section
  3. Inside /gen with git bash write command ./build.sh (sometimes need before used chmod +x build.sh)

Other Start

  1. Clone the repository:

    git clone <repository-URL>
    cd <repository-name>
  2. Build the project using Gradle:

    ./gradlew build
  3. If you want to build the Docker image, use the following command:

    docker build -t commmit-craft .
  4. Run the Docker container:

    docker run -d -p 8090:8090 --name commmit-craft commmit-craft
  5. The application will be available at http://localhost:8090.

Translate Module Integration with DeepL

The translate module integrates with DeepL for machine translation. To use this feature, you need to provide your DeepL API key.

Setup API Key

  1. Go to the translate module’s application.properties (or application.yml) file.

  2. Add your DeepL API key in the configuration:

    deepl.api.key=YOUR_DEEPL_API_KEY
  3. Replace YOUR_DEEPL_API_KEY with your actual API key obtained from DeepL.

Configuration

You can specify different profiles for the application. For example, to use the dev profile:

  1. In application.yml:

    spring.profiles.active=dev
  2. Alternatively, you can pass the active profile as a Docker environment variable:

    docker run -d -p 8090:8090 -e SPRING_PROFILES_ACTIVE=kam --name commmit-craft commmit-craft

Docker Configuration

Dockerfile

The Docker image uses Eclipse Temurin 17 and builds the application inside a Docker container. You can configure the profile or other settings when running the Docker container.

Exposed Port

By default, the application will run on port 8090. To change this, modify the application.properties:

server.port=8090

Running Tests

To run the tests for the application, use Gradle:

./gradlew test

Swagger documentation API

http://localhost:8090/swagger-ui/index.html

Adding a Dedicated Commit Template

Besides the built-in templates (conventional, detailed, markdown, quickly), you can register your own via the API.

POST http://localhost:8090/api/v1/craft-template/dedicated

{
    "name": "apilia-project-1",
    "description": "Dedykowany dla projektu coś tam",
    "pattern": "{ticket_id} {type}({scope}):{message}-{details}",
    "model": {
        "ticket_id": "Numer powiązanego zadania w JIRA",
        "type": ["feat", "fix", "junk", "chore", "test"],
        "scope": "[moduł lub komponent]",
        "message": "Krótki opis zmiany",
        "details": "Szczegóły zmian w treści commit message"
    }
}

Rules:

  • name must be unique — creating a template with an existing name returns 400.
  • Every placeholder used in pattern ({like_this}) must have a matching key in model, and every model key must appear in pattern — otherwise the request is rejected with 400 and a message listing the mismatched keys.
  • On success you get 201 with a confirmation message. The template then shows up in GET /api/v1/craft-template/all and can be removed with DELETE /api/v1/craft-template/removed/{name}.

Generating a Commit Message From a Template (with translation)

Once a template exists (built-in or dedicated), fill it in with real values to get the final commit message:

  • POST http://localhost:8090/api/v1/craft-template/generate?templateName=conventional — built-in templates
  • POST http://localhost:8090/api/v1/craft-template/generate-dedicated?templateName=apilia-project-1 — dedicated templates

Body is the commit data matching the template's model keys, e.g.:

{
    "ticket_id": "TEET-3455",
    "type": "feat",
    "scope": "auth",
    "message": "Zrobiłem te funkcje na sztos",
    "details": "Dodałem wiele różnych rzeczy i to jest fajne że mozna tak robić",
    "language": "EN"
}

Add an optional language field (e.g. "EN") to have every free-text model field (any key whose model value is a plain string, like message/details/scope above) translated via DeepL before the pattern is filled in. Fields whose model value is an array of allowed options (like type) are treated as fixed codes and are never translated. Omit language to keep the values exactly as sent, untranslated.

Persistence note: dedicated templates are stored in src/main/resources/templates/dedicated-meta-schema.json, resolved relative to the app's working directory — not read from the packaged jar's classpath. The Docker image copies this file in at build time so the endpoint works out of the box, but any template you add while the container is running is only written to that container's writable layer: it disappears once the container is removed/rebuilt. If you need dedicated templates to survive rebuilds, mount the folder as a volume, e.g.:

docker run -d -p 8090:8090 -v "$(pwd)/src/main/resources/templates:/commit-craft/src/main/resources/templates" --name commmit-craft commmit-craft

License

This project is licensed under the MIT License.

About

Commmit craft API is a tool designed to streamline the process of generating entire git commands in a development environment. By integrating with translation services such as DeepL, it allows commit messages to be easily translated, ensuring that they are clear, accurate and consistent across languages Uses a conventional-commits

Topics

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages