Add local format-code hook to pre-commit config

Introduces a new local hook 'format-code' that runs 'make apply-formatting' to ensure code formatting is applied automatically during pre-commit. The hook is set to always run.
This commit is contained in:
amithkoujalgi 2025-09-20 15:40:02 +05:30
parent cac94e0faf
commit 7a2a307a0a
No known key found for this signature in database
GPG Key ID: E29A37746AF94B70
5 changed files with 56 additions and 49 deletions

View File

@ -26,6 +26,14 @@ repos:
- id: commitizen - id: commitizen
stages: [commit-msg] stages: [commit-msg]
- repo: local
hooks:
- id: format-code
name: Format Code
entry: make apply-formatting
language: system
always_run: true
# # for java code quality # # for java code quality
# - repo: https://github.com/gherynos/pre-commit-java # - repo: https://github.com/gherynos/pre-commit-java
# rev: v0.6.10 # rev: v0.6.10

View File

@ -5,7 +5,7 @@
* Licensed under the MIT License (the "License"); * Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* *
*/ */
package io.github.ollama4j; package io.github.ollama4j;
import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.JsonParseException;

View File

@ -5,7 +5,7 @@
* Licensed under the MIT License (the "License"); * Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* *
*/ */
package io.github.ollama4j.models.chat; package io.github.ollama4j.models.chat;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;

View File

@ -5,7 +5,7 @@
* Licensed under the MIT License (the "License"); * Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* *
*/ */
package io.github.ollama4j.models.chat; package io.github.ollama4j.models.chat;
import io.github.ollama4j.utils.Options; import io.github.ollama4j.utils.Options;
@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.Setter; import lombok.Setter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -30,8 +29,7 @@ public class OllamaChatRequestBuilder {
private int imageURLConnectTimeoutSeconds = 10; private int imageURLConnectTimeoutSeconds = 10;
private int imageURLReadTimeoutSeconds = 10; private int imageURLReadTimeoutSeconds = 10;
@Setter @Setter private boolean useTools = true;
private boolean useTools = true;
public OllamaChatRequestBuilder withImageURLConnectTimeoutSeconds( public OllamaChatRequestBuilder withImageURLConnectTimeoutSeconds(
int imageURLConnectTimeoutSeconds) { int imageURLConnectTimeoutSeconds) {

View File

@ -5,7 +5,7 @@
* Licensed under the MIT License (the "License"); * Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* *
*/ */
package io.github.ollama4j.integrationtests; package io.github.ollama4j.integrationtests;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
@ -28,7 +28,12 @@ import io.github.ollama4j.tools.ToolFunction;
import io.github.ollama4j.tools.Tools; import io.github.ollama4j.tools.Tools;
import io.github.ollama4j.tools.annotations.OllamaToolService; import io.github.ollama4j.tools.annotations.OllamaToolService;
import io.github.ollama4j.utils.OptionsBuilder; import io.github.ollama4j.utils.OptionsBuilder;
import java.io.File;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URISyntaxException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
import org.junit.jupiter.api.Order; import org.junit.jupiter.api.Order;
@ -38,13 +43,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.testcontainers.ollama.OllamaContainer; import org.testcontainers.ollama.OllamaContainer;
import java.io.File;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URISyntaxException;
import java.util.*;
import java.util.concurrent.CountDownLatch;
@OllamaToolService(providers = {AnnotatedTool.class}) @OllamaToolService(providers = {AnnotatedTool.class})
@TestMethodOrder(OrderAnnotation.class) @TestMethodOrder(OrderAnnotation.class)
@SuppressWarnings({"HttpUrlsUsage", "SpellCheckingInspection", "FieldCanBeLocal", "ConstantValue"}) @SuppressWarnings({"HttpUrlsUsage", "SpellCheckingInspection", "FieldCanBeLocal", "ConstantValue"})
@ -1112,7 +1110,8 @@ class OllamaAPIIntegrationTest {
OllamaResult result = OllamaResult result =
api.generate( api.generate(
THINKING_TOOL_MODEL, THINKING_TOOL_MODEL,
"Count 1 to 5. Just give me the numbers and do not give any other details or information.", "Count 1 to 5. Just give me the numbers and do not give any other details"
+ " or information.",
raw, raw,
true, true,
new OptionsBuilder().setTemperature(0.1f).build(), new OptionsBuilder().setTemperature(0.1f).build(),
@ -1137,7 +1136,8 @@ class OllamaAPIIntegrationTest {
api.pullModel(TOOLS_MODEL); api.pullModel(TOOLS_MODEL);
String prompt = String prompt =
"Generate information about three major cities: their names, populations, and top attractions."; "Generate information about three major cities: their names, populations, and top"
+ " attractions.";
Map<String, Object> format = new HashMap<>(); Map<String, Object> format = new HashMap<>();
format.put("type", "object"); format.put("type", "object");
@ -1270,7 +1270,8 @@ class OllamaAPIIntegrationTest {
OllamaChatRequest requestModel = OllamaChatRequest requestModel =
builder.withMessage( builder.withMessage(
OllamaChatMessageRole.USER, OllamaChatMessageRole.USER,
"I need to find information about employee John Smith. Think carefully about what details to retrieve.") "I need to find information about employee John Smith. Think"
+ " carefully about what details to retrieve.")
.withThinking(true) .withThinking(true)
.withOptions(new OptionsBuilder().setTemperature(0.1f).build()) .withOptions(new OptionsBuilder().setTemperature(0.1f).build())
.build(); .build();