From ed08062ba504efa127d3a5f2918884d66d03c0fa Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Mon, 19 Jan 2026 20:43:02 +0530 Subject: [PATCH 01/24] docs(readme): add documentation badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 286bdb1..3a995dc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # AMRIT - BeneficiaryID-Generation-API Service -[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) ![branch parameter](https://github.com/PSMRI/HWC-API/actions/workflows/sast-and-package.yml/badge.svg) +[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![DeepWiki](https://img.shields.io/badge/DeepWiki-PSMRI%2FBeneficiaryID--Generation--API-blue)](https://deepwiki.com/PSMRI/BeneficiaryID-Generation-API) + This service is used to generate unique beneficiary registration Id for new beneficiaries. From 01c25bd6af1581d1845c04fda4520c7a41e474d2 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Tue, 3 Feb 2026 13:04:48 +0530 Subject: [PATCH 02/24] chore(swagger): automate swagger sync to amrit-docs --- .github/workflows/swagger-json.yml | 88 +++++++++++++++++++ pom.xml | 11 ++- .../common/bengen/utils/FilterConfig.java | 2 + .../utils/JwtUserIdValidationFilter.java | 5 ++ .../resources/application-swagger.properties | 23 +++++ 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/swagger-json.yml create mode 100644 src/main/resources/application-swagger.properties diff --git a/.github/workflows/swagger-json.yml b/.github/workflows/swagger-json.yml new file mode 100644 index 0000000..5669593 --- /dev/null +++ b/.github/workflows/swagger-json.yml @@ -0,0 +1,88 @@ +name: Sync Swagger to AMRIT-Docs + +on: + push: + branches: [ main ] + workflow_dispatch: + +jobs: + swagger-sync: + runs-on: ubuntu-latest + + steps: + - name: Checkout API repo + uses: actions/checkout@v4 + + - name: Set up Java 17 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: maven + + - name: Build API (skip tests) + run: mvn clean package -DskipTests + + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + + - name: Run API in swagger profile + run: | + mvn spring-boot:run \ + -Dspring-boot.run.profiles=swagger \ + -Dspring-boot.run.arguments=--server.port=9090 \ + > app.log 2>&1 & + echo $! > api_pid.txt + + - name: Wait for API & fetch Swagger + run: | + for i in {1..30}; do + CODE=$(curl --connect-timeout 2 --max-time 5 -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true) + if [ "$CODE" = "200" ]; then + if jq . swagger_raw.json > beneficiaryid-generation-api.json; then + echo "Swagger generated successfully" + exit 0 + else + echo "Failed to parse swagger_raw.json with jq" + exit 1 + fi + fi + echo "Waiting for API... ($i)" + sleep 5 + done + + echo "Swagger not generated" + cat app.log || true + exit 1 + + - name: Stop API + if: always() + run: | + if [ -f api_pid.txt ]; then + kill $(cat api_pid.txt) || true + fi + + - name: Checkout AMRIT-Docs + uses: actions/checkout@v4 + with: + repository: PSMRI/AMRIT-Docs + token: ${{ secrets.DOCS_REPO_TOKEN }} + path: amrit-docs + + - name: Copy Swagger JSON + run: | + mkdir -p amrit-docs/docs/swagger + cp beneficiaryid-generation-api.json amrit-docs/docs/swagger/beneficiaryid-generation-api.json + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.DOCS_REPO_TOKEN }} + path: amrit-docs + branch: auto/swagger-update-${{ github.run_id }} + base: main + commit-message: Auto-update BeneficiaryID-Generation-API swagger + title: Auto-update BeneficiaryID-Generation-API swagger + body: | + This PR automatically updates the BeneficiaryID-Generation-API Swagger JSON + from the latest main branch build. diff --git a/pom.xml b/pom.xml index 9ebc49c..b7e7ed3 100644 --- a/pom.xml +++ b/pom.xml @@ -385,7 +385,16 @@ 0.12.6 runtime - + + com.h2database + h2 + runtime + + + org.springdoc + springdoc-openapi-starter-webmvc-ui + 2.3.0 + diff --git a/src/main/java/com/iemr/common/bengen/utils/FilterConfig.java b/src/main/java/com/iemr/common/bengen/utils/FilterConfig.java index 45cf745..10cdb4f 100644 --- a/src/main/java/com/iemr/common/bengen/utils/FilterConfig.java +++ b/src/main/java/com/iemr/common/bengen/utils/FilterConfig.java @@ -5,8 +5,10 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; @Configuration +@Profile("!swagger") public class FilterConfig { @Value("${cors.allowed-origins}") diff --git a/src/main/java/com/iemr/common/bengen/utils/JwtUserIdValidationFilter.java b/src/main/java/com/iemr/common/bengen/utils/JwtUserIdValidationFilter.java index b6b57c0..ababf80 100644 --- a/src/main/java/com/iemr/common/bengen/utils/JwtUserIdValidationFilter.java +++ b/src/main/java/com/iemr/common/bengen/utils/JwtUserIdValidationFilter.java @@ -1,5 +1,8 @@ package com.iemr.common.bengen.utils; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + import java.io.IOException; import java.util.Arrays; @@ -18,6 +21,8 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; +@Profile("!swagger") +@Component public class JwtUserIdValidationFilter implements Filter { private final JwtAuthenticationUtil jwtAuthenticationUtil; diff --git a/src/main/resources/application-swagger.properties b/src/main/resources/application-swagger.properties new file mode 100644 index 0000000..6487467 --- /dev/null +++ b/src/main/resources/application-swagger.properties @@ -0,0 +1,23 @@ + +spring.datasource.url=jdbc:h2:mem:swaggerdb +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.jpa.hibernate.ddl-auto=none + +# Disable Redis if not needed for docs (optional) +spring.redis.host=localhost +spring.redis.port=6379 + +# CORS for Swagger UI +cors.allowed-origins=${CORS_ALLOWED_ORIGINS:http://localhost:9090,http://localhost:8080} + +# Logging +logging.level.root=INFO + +# Disable security auto-configuration (already excluded in main class) +# If you have custom security beans, add @Profile("!swagger") to them + +jwt.secret= JWT_SECRET +spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration \ No newline at end of file From 6c4bb1669d05aa0359a5e602599b0ec81ed069bf Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Wed, 11 Feb 2026 10:32:29 +0530 Subject: [PATCH 03/24] chore(swagger): update swagger workflow --- .github/workflows/swagger-json.yml | 57 ++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/.github/workflows/swagger-json.yml b/.github/workflows/swagger-json.yml index 5669593..dfa8ee8 100644 --- a/.github/workflows/swagger-json.yml +++ b/.github/workflows/swagger-json.yml @@ -8,6 +8,7 @@ on: jobs: swagger-sync: runs-on: ubuntu-latest + timeout-minutes: 20 steps: - name: Checkout API repo @@ -21,34 +22,42 @@ jobs: cache: maven - name: Build API (skip tests) - run: mvn clean package -DskipTests - + run: mvn -B clean package -DskipTests + - name: Install jq run: sudo apt-get update && sudo apt-get install -y jq - name: Run API in swagger profile run: | - mvn spring-boot:run \ - -Dspring-boot.run.profiles=swagger \ - -Dspring-boot.run.arguments=--server.port=9090 \ + nohup java -jar target/beneficiaryid-generation-api-*.war \ + --spring.profiles.active=swagger \ + --server.port=9090 \ > app.log 2>&1 & echo $! > api_pid.txt - name: Wait for API & fetch Swagger run: | - for i in {1..30}; do + for i in {1..40}; do CODE=$(curl --connect-timeout 2 --max-time 5 -s -o swagger_raw.json -w "%{http_code}" http://localhost:9090/v3/api-docs || true) + if [ "$CODE" = "200" ]; then - if jq . swagger_raw.json > beneficiaryid-generation-api.json; then - echo "Swagger generated successfully" - exit 0 - else - echo "Failed to parse swagger_raw.json with jq" + jq . swagger_raw.json > beneficiaryid-generation-api.json || { + echo "Swagger JSON invalid" + cat swagger_raw.json + exit 1 + } + + if [ "$(jq '.paths | length' beneficiaryid-generation-api.json)" -eq 0 ]; then + echo "Swagger paths empty – failing" exit 1 fi + + echo "Swagger generated successfully" + exit 0 fi + echo "Waiting for API... ($i)" - sleep 5 + sleep 4 done echo "Swagger not generated" @@ -58,9 +67,17 @@ jobs: - name: Stop API if: always() run: | + # Graceful shutdown of the process group + sleep 5 + # Force kill the process group if still running if [ -f api_pid.txt ]; then - kill $(cat api_pid.txt) || true - fi + PID=$(cat api_pid.txt) + kill -TERM -- -"$PID" 2>/dev/null || true + sleep 2 + kill -9 -- -"$PID" 2>/dev/null || true + fi + # Fallback: kill any remaining java process on port 9090 + fuser -k 9090/tcp 2>/dev/null || true - name: Checkout AMRIT-Docs uses: actions/checkout@v4 @@ -68,6 +85,7 @@ jobs: repository: PSMRI/AMRIT-Docs token: ${{ secrets.DOCS_REPO_TOKEN }} path: amrit-docs + fetch-depth: 0 - name: Copy Swagger JSON run: | @@ -75,14 +93,15 @@ jobs: cp beneficiaryid-generation-api.json amrit-docs/docs/swagger/beneficiaryid-generation-api.json - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@v8 with: token: ${{ secrets.DOCS_REPO_TOKEN }} path: amrit-docs - branch: auto/swagger-update-${{ github.run_id }} + branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }} base: main - commit-message: Auto-update BeneficiaryID-Generation-API swagger - title: Auto-update BeneficiaryID-Generation-API swagger + commit-message: "chore(docs): auto-update BeneficiaryID-Generation-API swagger" + title: "chore(docs): auto-update BeneficiaryID-Generation-API swagger" + delete-branch: true body: | - This PR automatically updates the BeneficiaryID-Generation-API Swagger JSON + This PR automatically updates BeneficiaryID-Generation-API Swagger JSON from the latest main branch build. From e4a5bcef5f6fd347a113a6e77e7a5afbff6689d7 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Wed, 11 Feb 2026 10:38:44 +0530 Subject: [PATCH 04/24] fix(swagger): fix github workflow running issue --- .github/workflows/swagger-json.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/swagger-json.yml b/.github/workflows/swagger-json.yml index dfa8ee8..560b4bd 100644 --- a/.github/workflows/swagger-json.yml +++ b/.github/workflows/swagger-json.yml @@ -29,9 +29,9 @@ jobs: - name: Run API in swagger profile run: | - nohup java -jar target/beneficiaryid-generation-api-*.war \ - --spring.profiles.active=swagger \ - --server.port=9090 \ + mvn spring-boot:run \ + -Dspring-boot.run.profiles=swagger \ + -Dspring-boot.run.arguments=--server.port=9090 \ > app.log 2>&1 & echo $! > api_pid.txt From 081d21699d2b585395b8b800d7e7d63877ff489e Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 12 Feb 2026 14:39:14 +0530 Subject: [PATCH 05/24] chore(swagger): add env-driven Dev/UAT/Demo servers, update and uncomment the SwaggerConfig.java --- .github/workflows/swagger-json.yml | 2 +- .../common/bengen/config/SwaggerConfig.java | 111 ++++++++++-------- .../resources/application-swagger.properties | 6 +- 3 files changed, 65 insertions(+), 54 deletions(-) diff --git a/.github/workflows/swagger-json.yml b/.github/workflows/swagger-json.yml index 560b4bd..0b6e4dc 100644 --- a/.github/workflows/swagger-json.yml +++ b/.github/workflows/swagger-json.yml @@ -97,7 +97,7 @@ jobs: with: token: ${{ secrets.DOCS_REPO_TOKEN }} path: amrit-docs - branch: auto/swagger-update-${{ github.run_id }}-${{ github.run_attempt }} + branch: auto/swagger-update-beneficiaryid-generation-api base: main commit-message: "chore(docs): auto-update BeneficiaryID-Generation-API swagger" title: "chore(docs): auto-update BeneficiaryID-Generation-API swagger" diff --git a/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java b/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java index 45199e2..e326bef 100644 --- a/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java +++ b/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java @@ -1,52 +1,59 @@ -///* -//* AMRIT - Accessible Medical Records via Integrated Technologies -//* Integrated EHR (Electronic Health Records) Solution -//* -//* Copyright (C) "Piramal Swasthya Management and Research Institute" -//* -//* This file is part of AMRIT. -//* -//* This program is free software: you can redistribute it and/or modify -//* it under the terms of the GNU General Public License as published by -//* the Free Software Foundation, either version 3 of the License, or -//* (at your option) any later version. -//* -//* This program is distributed in the hope that it will be useful, -//* but WITHOUT ANY WARRANTY; without even the implied warranty of -//* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//* GNU General Public License for more details. -//* -//* You should have received a copy of the GNU General Public License -//* along with this program. If not, see https://www.gnu.org/licenses/. -//*/ -//package com.iemr.common.bengen.config; -// -//import org.springframework.context.annotation.Bean; -//import org.springframework.context.annotation.Configuration; -// -//import springfox.documentation.builders.RequestHandlerSelectors; -//import springfox.documentation.service.ApiInfo; -//import springfox.documentation.service.Contact; -//import springfox.documentation.spi.DocumentationType; -//import springfox.documentation.spring.web.plugins.Docket; -//import springfox.documentation.swagger2.annotations.EnableSwagger2; -// -//@Configuration -//@EnableSwagger2 -//public class SwaggerConfig { -// @Bean -// public Docket productApi() { -// return new Docket(DocumentationType.SWAGGER_2).select() -// .apis(RequestHandlerSelectors.basePackage("com.iemr.common.bengen.controller")) -//// /* .paths(regex("/*.*")) */ -// .build().apiInfo(metaData()); -// } -// -// private ApiInfo metaData() { -// ApiInfo apiInfo = new ApiInfo("BeneficiaryID-Generation API", -// "This service is used to generate unique beneficiary registration Id for new beneficiaries.", -// "1.0", "Terms of service", new Contact("AMRIT", "https://psmri.github.io/PSMRI/", "amrit@piramalswasthya.org"), -// "", ""); -// return apiInfo; -// } -//} \ No newline at end of file +/* +* AMRIT - Accessible Medical Records via Integrated Technologies +* Integrated EHR (Electronic Health Records) Solution +* +* Copyright (C) "Piramal Swasthya Management and Research Institute" +* +* This file is part of AMRIT. +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see https://www.gnu.org/licenses/. +*/ +package com.iemr.common.bengen.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; + + +@Configuration +public class SwaggerConfig { + private static final String DEFAULT_SERVER_URL = "http://localhost:9090"; + + @Bean + public OpenAPI customOpenAPI(Environment env) { + String devUrl = env.getProperty("api.dev.url", DEFAULT_SERVER_URL); + String uatUrl = env.getProperty("api.uat.url", DEFAULT_SERVER_URL); + String demoUrl = env.getProperty("api.demo.url", DEFAULT_SERVER_URL); + return new OpenAPI() + .info(new Info() + .title("BeneficiaryID-Generation API") + .version("1.0") + .description("This service is used to generate unique beneficiary registration Id for new beneficiaries.")) + .addSecurityItem(new SecurityRequirement().addList("my security")) + .components(new Components().addSecuritySchemes("my security", + new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer"))) + .servers(java.util.Arrays.asList( + new Server().url(devUrl).description("Dev"), + new Server().url(uatUrl).description("UAT"), + new Server().url(demoUrl).description("Demo") + )); + } +} \ No newline at end of file diff --git a/src/main/resources/application-swagger.properties b/src/main/resources/application-swagger.properties index 6487467..160a4ea 100644 --- a/src/main/resources/application-swagger.properties +++ b/src/main/resources/application-swagger.properties @@ -1,3 +1,7 @@ +# Swagger server URLs +api.dev.url=${API_DEV_URL:https://amritwprdev.piramalswasthya.org} +api.uat.url=${API_UAT_URL:https://uatamrit.piramalswasthya.org} +api.demo.url=${API_DEMO_URL:https://amritdemo.piramalswasthya.org} spring.datasource.url=jdbc:h2:mem:swaggerdb spring.datasource.driver-class-name=org.h2.Driver @@ -19,5 +23,5 @@ logging.level.root=INFO # Disable security auto-configuration (already excluded in main class) # If you have custom security beans, add @Profile("!swagger") to them -jwt.secret= JWT_SECRET +jwt.secret= ${JWT_SECRET_KEY:#{T(java.util.UUID).randomUUID().toString()}} spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration \ No newline at end of file From edb483ed24955d0cd140ff3288006f6aefe5e7e1 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 12 Feb 2026 14:45:22 +0530 Subject: [PATCH 06/24] chore(swagger): deduplicate SwaggerConfig and extract constants --- .../java/com/iemr/common/bengen/config/SwaggerConfig.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java b/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java index e326bef..09517dc 100644 --- a/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java +++ b/src/main/java/com/iemr/common/bengen/config/SwaggerConfig.java @@ -36,6 +36,7 @@ @Configuration public class SwaggerConfig { private static final String DEFAULT_SERVER_URL = "http://localhost:9090"; + private static final String SECURITY_SCHEME_NAME = "my security"; @Bean public OpenAPI customOpenAPI(Environment env) { @@ -47,9 +48,9 @@ public OpenAPI customOpenAPI(Environment env) { .title("BeneficiaryID-Generation API") .version("1.0") .description("This service is used to generate unique beneficiary registration Id for new beneficiaries.")) - .addSecurityItem(new SecurityRequirement().addList("my security")) - .components(new Components().addSecuritySchemes("my security", - new SecurityScheme().name("my security").type(SecurityScheme.Type.HTTP).scheme("bearer"))) + .addSecurityItem(new SecurityRequirement().addList(SECURITY_SCHEME_NAME)) + .components(new Components().addSecuritySchemes(SECURITY_SCHEME_NAME, + new SecurityScheme().name(SECURITY_SCHEME_NAME).type(SecurityScheme.Type.HTTP).scheme("bearer"))) .servers(java.util.Arrays.asList( new Server().url(devUrl).description("Dev"), new Server().url(uatUrl).description("UAT"), From 88cf2319a02e29f68ca08c01ef5475ca63f08053 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 12 Feb 2026 14:52:31 +0530 Subject: [PATCH 07/24] chore(swagger): fix the jwt token issue in properties --- src/main/resources/application-swagger.properties | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/resources/application-swagger.properties b/src/main/resources/application-swagger.properties index 160a4ea..68c2f6a 100644 --- a/src/main/resources/application-swagger.properties +++ b/src/main/resources/application-swagger.properties @@ -19,9 +19,5 @@ cors.allowed-origins=${CORS_ALLOWED_ORIGINS:http://localhost:9090,http://localho # Logging logging.level.root=INFO - -# Disable security auto-configuration (already excluded in main class) -# If you have custom security beans, add @Profile("!swagger") to them - jwt.secret= ${JWT_SECRET_KEY:#{T(java.util.UUID).randomUUID().toString()}} spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration \ No newline at end of file From 01041c5a82d95870e2d551344077d70a1514908f Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Wed, 4 Mar 2026 18:13:56 +0530 Subject: [PATCH 08/24] feat(git-hooks): add commit message validation using commit-msg hook --- .git-hooks/commit-msg | 20 ++++++++++++++++++++ commitlint.config.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 .git-hooks/commit-msg create mode 100644 commitlint.config.js diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg new file mode 100644 index 0000000..4122202 --- /dev/null +++ b/.git-hooks/commit-msg @@ -0,0 +1,20 @@ +#!/bin/sh + +commit_regex='^(feat|fix|docs|style|refactor|test|chore)(\([a-zA-Z0-9_-]+\))?: .+' + +commit_msg=$(cat "$1") + +if ! echo "$commit_msg" | grep -Eq "$commit_regex"; then + echo "" + echo "Invalid commit message" + echo "" + echo "Required format:" + echo "type(scope): description" + echo "" + echo "Example:" + echo "feat(auth): add login API" + echo "" + echo "Allowed types:" + echo "feat | fix | docs | style | refactor | test | chore" + exit 1 +fi \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..59a0dbc --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,29 @@ +module.exports = { + extends: ['@commitlint/config-conventional'], + rules: { + 'type-enum': [ + 2, + 'always', + [ + 'feat', // A new feature + 'fix', // A bug fix + 'docs', // Documentation only changes + 'style', // Changes that don't affect code meaning (formatting, semicolons, etc.) + 'refactor', // Code change that neither fixes a bug nor adds a feature + 'perf', // Code change that improves performance + 'test', // Adding missing tests or correcting existing tests + 'chore', // Changes to build process, dependencies, tools, etc. + 'ci', // Changes to CI/CD configuration files + 'revert', // Revert a previous commit + ], + ], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], + 'scope-empty': [0], + 'scope-case': [2, 'always', 'lower-case'], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']], + 'header-max-length': [2, 'always', 100], + }, +}; From 02c926b630d022b7ef65e429c649da5e8ccd3deb Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 09:41:23 +0530 Subject: [PATCH 09/24] feat(git-hooks): add git-hook for check pre commit --- .git-hooks/commit-msg | 3 +++ .github/workflows/commit-check.yml | 25 +++++++++++++++++++++++++ commitlint.config.js | 12 ++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 .git-hooks/commit-msg create mode 100644 .github/workflows/commit-check.yml create mode 100644 commitlint.config.js diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg new file mode 100644 index 0000000..0492f2e --- /dev/null +++ b/.git-hooks/commit-msg @@ -0,0 +1,3 @@ +#!/bin/sh + +npx --no-install commitlint --edit "$1" \ No newline at end of file diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml new file mode 100644 index 0000000..a501951 --- /dev/null +++ b/.github/workflows/commit-check.yml @@ -0,0 +1,25 @@ +name: Commit Message Check + +on: + pull_request: + types: [opened, synchronize, reopened] + +jobs: + commit-check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Validate commit messages + run: | + regex='^(feat|fix|docs|style|refactor|test|chore)(\([a-zA-Z0-9_-]+\))?: .+' + + commits=$(git log origin/main..HEAD --pretty=format:%s) + + for commit in $commits; do + if ! echo "$commit" | grep -Eq "$regex"; then + echo "Invalid commit message: $commit" + exit 1 + fi + done \ No newline at end of file diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000..eff7f90 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,12 @@ +module.exports = { + rules: { + 'type-enum': [ + 2, + 'always', + ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore'] + ], + 'type-case': [2, 'always', 'lower-case'], + 'subject-empty': [2, 'never'], + 'subject-case': [0] + } +}; \ No newline at end of file From 01a6e7cd4c6e2f1c894566c4e142a01506559789 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 10:21:05 +0530 Subject: [PATCH 10/24] chore(workflow): enforce scoped commit message format --- .github/workflows/commit-check.yml | 6 ++---- commitlint.config.js | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index a501951..8e96ac0 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -13,11 +13,9 @@ jobs: - name: Validate commit messages run: | - regex='^(feat|fix|docs|style|refactor|test|chore)(\([a-zA-Z0-9_-]+\))?: .+' - - commits=$(git log origin/main..HEAD --pretty=format:%s) + regex='^(feat|fix|docs|style|refactor|test|chore)\([a-zA-Z0-9_-]+\): .+' - for commit in $commits; do + git log --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.sha }} | while read commit; do if ! echo "$commit" | grep -Eq "$regex"; then echo "Invalid commit message: $commit" exit 1 diff --git a/commitlint.config.js b/commitlint.config.js index 12eecf6..29eee37 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -6,7 +6,8 @@ module.exports = { ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore'] ], 'type-case': [2, 'always', 'lower-case'], + 'scope-empty': [2, 'never'], 'subject-empty': [2, 'never'], 'subject-case': [0] } -}; +}; \ No newline at end of file From 3ac21029c74305763f2be2640c49d49a3aaa64a8 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Wed, 4 Mar 2026 18:13:56 +0530 Subject: [PATCH 11/24] feat(git-hooks): add commit message validation using commit-msg hook --- commitlint.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitlint.config.js b/commitlint.config.js index 29eee37..7f9130a 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -10,4 +10,4 @@ module.exports = { 'subject-empty': [2, 'never'], 'subject-case': [0] } -}; \ No newline at end of file +}; From c1e88017a9b8282c1a7c38ec519b843abcd8cabd Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 12:30:57 +0530 Subject: [PATCH 12/24] chore(commit): update workflow and hooks based on coderabbit feedback --- .github/workflows/commit-check.yml | 16 +++++++++------- README.md | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 8e96ac0..316fb53 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -10,14 +10,16 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Validate commit messages run: | - regex='^(feat|fix|docs|style|refactor|test|chore)\([a-zA-Z0-9_-]+\): .+' + regex='^(feat|fix|docs|style|refactor|test|chore)\([a-zA-Z0-9_\-\.]+\): .+' - git log --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.sha }} | while read commit; do - if ! echo "$commit" | grep -Eq "$regex"; then - echo "Invalid commit message: $commit" - exit 1 - fi - done \ No newline at end of file + invalid=$(git log --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.sha }} | grep -Ev "$regex" || true) + if [ -n "$invalid" ]; then + echo "Invalid commit messages found:" + echo "$invalid" + exit 1 + fi \ No newline at end of file diff --git a/README.md b/README.md index 3a995dc..b38db59 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,31 @@ Find the detailed list of software dependencies [here] (https://piramal-swasthya * Redis * MySQL Database +## Commit Message Validation + +This repository enforces commit message format using a Git `commit-msg` hook and GitHub workflow. + +### Commit Format + +All commits must follow this format: + +type(scope): message + +### Enable Git Hooks + +After cloning the repository, run the following command once to activate the hooks: + +git config core.hooksPath .git-hooks + +This enables the `commit-msg` hook located in the `.git-hooks` directory. + +### Validation + +Commit messages are validated in two ways: + +1. Local Git hook using Commitlint via `npx` +2. GitHub workflow that checks commit messages during pull requests + ### Installation and setup Please follow these steps: From 86e1f4d319627fafd6c43ed64be8226671c468e2 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 13:10:52 +0530 Subject: [PATCH 13/24] chore(commit): update commit types in workflow and config --- .github/workflows/commit-check.yml | 2 +- README.md | 2 +- commitlint.config.js | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 316fb53..f715226 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -15,7 +15,7 @@ jobs: - name: Validate commit messages run: | - regex='^(feat|fix|docs|style|refactor|test|chore)\([a-zA-Z0-9_\-\.]+\): .+' + regex='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\([a-zA-Z0-9_\-\.]+\): .+' invalid=$(git log --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.sha }} | grep -Ev "$regex" || true) if [ -n "$invalid" ]; then diff --git a/README.md b/README.md index b38db59..8876b18 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ type(scope): message After cloning the repository, run the following command once to activate the hooks: -git config core.hooksPath .git-hooks +`git config core.hooksPath .git-hooks` This enables the `commit-msg` hook located in the `.git-hooks` directory. diff --git a/commitlint.config.js b/commitlint.config.js index 7f9130a..86b04e0 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -3,7 +3,17 @@ module.exports = { 'type-enum': [ 2, 'always', - ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore'] + ['build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test'] ], 'type-case': [2, 'always', 'lower-case'], 'scope-empty': [2, 'never'], From 34b4b6314f17e76b8c1cba9046fc46ac7f860e5e Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 13:19:24 +0530 Subject: [PATCH 14/24] fix(ci): ignore merge commits in commit message validation --- .github/workflows/commit-check.yml | 7 +++++-- README.md | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index f715226..b85ebc0 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -17,9 +17,12 @@ jobs: run: | regex='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\([a-zA-Z0-9_\-\.]+\): .+' - invalid=$(git log --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.sha }} | grep -Ev "$regex" || true) + invalid=$(git log --no-merges --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | grep -Ev "$regex" || true) + if [ -n "$invalid" ]; then echo "Invalid commit messages found:" echo "$invalid" exit 1 - fi \ No newline at end of file + fi + + echo "All commit messages follow the required format." \ No newline at end of file diff --git a/README.md b/README.md index 8876b18..f4e2356 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This repository enforces commit message format using a Git `commit-msg` hook and All commits must follow this format: -type(scope): message +`type(scope): message` ### Enable Git Hooks From 4c124552f7c30e457e17221ef4ef756ab6823d86 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 13:33:17 +0530 Subject: [PATCH 15/24] refactor(ci): replace regex commit check with commitlint validation --- .github/workflows/commit-check.yml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index b85ebc0..5cb7f64 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -13,16 +13,12 @@ jobs: with: fetch-depth: 0 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Validate commit messages run: | - regex='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)\([a-zA-Z0-9_\-\.]+\): .+' - - invalid=$(git log --no-merges --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | grep -Ev "$regex" || true) - - if [ -n "$invalid" ]; then - echo "Invalid commit messages found:" - echo "$invalid" - exit 1 - fi - - echo "All commit messages follow the required format." \ No newline at end of file + git log --no-merges --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | while IFS= read -r commit; do + echo "$commit" | npx --no-install commitlint + done \ No newline at end of file From eb785ba82b9d09683b22666d326726e4b9e21430 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 13:47:22 +0530 Subject: [PATCH 16/24] fix(ci): run commitlint via npx without local dependency --- .git-hooks/commit-msg | 2 +- .github/workflows/commit-check.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg index ca25ce1..c74610c 100644 --- a/.git-hooks/commit-msg +++ b/.git-hooks/commit-msg @@ -1,3 +1,3 @@ #!/bin/sh -npx --no-install commitlint --edit "$1" +npx --yes @commitlint/cli --edit "$1" \ No newline at end of file diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 5cb7f64..ff8a820 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -20,5 +20,5 @@ jobs: - name: Validate commit messages run: | git log --no-merges --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | while IFS= read -r commit; do - echo "$commit" | npx --no-install commitlint + echo "$commit" | npx --yes @commitlint/cli done \ No newline at end of file From 310595928e1d1dacd916b51787f6aeedf6c8714b Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 14:11:50 +0530 Subject: [PATCH 17/24] refactor(ci): use commitlint range validation with pinned version --- .github/workflows/commit-check.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index ff8a820..2d25f5e 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -19,6 +19,7 @@ jobs: - name: Validate commit messages run: | - git log --no-merges --pretty=format:%s ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | while IFS= read -r commit; do - echo "$commit" | npx --yes @commitlint/cli - done \ No newline at end of file + npx --yes @commitlint/cli@20.4.3 \ + --from "${{ github.event.pull_request.base.sha }}" \ + --to "${{ github.event.pull_request.head.sha }}" \ + --git-log-args "--no-merges" \ No newline at end of file From 9350b5d387eb0554109e7604daac085d977e71d4 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 14:20:36 +0530 Subject: [PATCH 18/24] fix(ci): correct git-log-args quoting in commitlint workflow --- .github/workflows/commit-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 2d25f5e..358ff86 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -22,4 +22,4 @@ jobs: npx --yes @commitlint/cli@20.4.3 \ --from "${{ github.event.pull_request.base.sha }}" \ --to "${{ github.event.pull_request.head.sha }}" \ - --git-log-args "--no-merges" \ No newline at end of file + --git-log-args '--no-merges' \ No newline at end of file From c8f1b6508bd0ab71dbcc0970ad911e92f363110a Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 14:25:34 +0530 Subject: [PATCH 19/24] fix(ci): skip merge commits in commitlint workflow --- .github/workflows/commit-check.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 358ff86..2a3b1cd 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -19,7 +19,8 @@ jobs: - name: Validate commit messages run: | - npx --yes @commitlint/cli@20.4.3 \ - --from "${{ github.event.pull_request.base.sha }}" \ - --to "${{ github.event.pull_request.head.sha }}" \ - --git-log-args '--no-merges' \ No newline at end of file + git log \ + --no-merges \ + --pretty=format:"%s" \ + "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" \ + | npx --yes @commitlint/cli@20.4.3 --from-stdin \ No newline at end of file From 7c81ca01a3ae73e680699e0bc82480a901bfe55c Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 14:29:14 +0530 Subject: [PATCH 20/24] fix(ci): validate PR commits using commitlint --- .github/workflows/commit-check.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 2a3b1cd..406de57 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -21,6 +21,11 @@ jobs: run: | git log \ --no-merges \ - --pretty=format:"%s" \ + --pretty=format:"%H" \ "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" \ - | npx --yes @commitlint/cli@20.4.3 --from-stdin \ No newline at end of file + | while IFS= read -r sha; do + tmp=$(mktemp) + git log -1 --pretty=format:"%B" "$sha" > "$tmp" + npx --yes @commitlint/cli@20.4.3 --edit "$tmp" || exit 1 + rm "$tmp" + done \ No newline at end of file From cc0e6dcf81ad7456cf1cef1cedbca17e0a895868 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 15:55:41 +0530 Subject: [PATCH 21/24] docs(readme): add git hooks enable command in setup --- README.md | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index f4e2356..b483c24 100644 --- a/README.md +++ b/README.md @@ -15,43 +15,20 @@ Find the detailed list of software dependencies [here] (https://piramal-swasthya * Redis * MySQL Database -## Commit Message Validation - -This repository enforces commit message format using a Git `commit-msg` hook and GitHub workflow. - -### Commit Format - -All commits must follow this format: - -`type(scope): message` - -### Enable Git Hooks - -After cloning the repository, run the following command once to activate the hooks: - -`git config core.hooksPath .git-hooks` - -This enables the `commit-msg` hook located in the `.git-hooks` directory. - -### Validation - -Commit messages are validated in two ways: - -1. Local Git hook using Commitlint via `npx` -2. GitHub workflow that checks commit messages during pull requests - ### Installation and setup Please follow these steps: 1. Clone the repository to your local machine. -2. Install the dependencies and build the module: +2. Enable git hooks (run once after cloning): + - Run the command `git config core.hooksPath .git-hooks`. +3. Install the dependencies and build the module: - Run the command `mvn clean install`. -3. You can copy `bengen_example.properties` to `bengen_local.properties` and edit the file accordingly. The file is under `src/main/environment` folder. -4. Run the development server: +4. You can copy `bengen_example.properties` to `bengen_local.properties` and edit the file accordingly. The file is under `src/main/environment` folder. +5. Run the development server: - Start the Redis server. - Run the command `mvn spring-boot:run -DENV_VAR=local`. -5. Open your browser and access `http://localhost:8080/swagger-ui.html#!/` to view the Swagger API documentation. +6. Open your browser and access `http://localhost:8080/swagger-ui.html#!/` to view the Swagger API documentation. ## Usage From fa7ad694fdeb844836862a8fb34c0a7729b4206a Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 17:04:24 +0530 Subject: [PATCH 22/24] refactor(commitlint): define commit rules directly without config-conventional --- commitlint.config.js | 46 ++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/commitlint.config.js b/commitlint.config.js index 86b04e0..abc565a 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1,23 +1,35 @@ module.exports = { rules: { + 'body-leading-blank': [1, 'always'], + 'body-max-line-length': [2, 'always', 100], + 'footer-leading-blank': [1, 'always'], + 'footer-max-line-length': [2, 'always', 100], + 'header-max-length': [2, 'always', 100], + 'subject-case': [ + 2, + 'never', + ['sentence-case', 'start-case', 'pascal-case', 'upper-case'], + ], + 'subject-empty': [2, 'never'], + 'subject-full-stop': [2, 'never', '.'], + 'type-case': [2, 'always', 'lower-case'], + 'type-empty': [2, 'never'], 'type-enum': [ 2, 'always', - ['build', - 'chore', - 'ci', - 'docs', - 'feat', - 'fix', - 'perf', - 'refactor', - 'revert', - 'style', - 'test'] + [ + 'build', + 'chore', + 'ci', + 'docs', + 'feat', + 'fix', + 'perf', + 'refactor', + 'revert', + 'style', + 'test', + ], ], - 'type-case': [2, 'always', 'lower-case'], - 'scope-empty': [2, 'never'], - 'subject-empty': [2, 'never'], - 'subject-case': [0] - } -}; + }, +}; \ No newline at end of file From 0a40616a132031d0cc23b62d51cb4f7cd65f90d1 Mon Sep 17 00:00:00 2001 From: DurgaPrasad-54 Date: Thu, 5 Mar 2026 20:09:01 +0530 Subject: [PATCH 23/24] fix(commitlint): handle exit codes correctly in workflow --- .git-hooks/commit-msg | 3 ++- .github/workflows/commit-check.yml | 18 ++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg index c74610c..f27de35 100644 --- a/.git-hooks/commit-msg +++ b/.git-hooks/commit-msg @@ -1,3 +1,4 @@ #!/bin/sh +set -e -npx --yes @commitlint/cli --edit "$1" \ No newline at end of file +npx --yes @commitlint/cli --edit "$1" diff --git a/.github/workflows/commit-check.yml b/.github/workflows/commit-check.yml index 406de57..aaad8ad 100644 --- a/.github/workflows/commit-check.yml +++ b/.github/workflows/commit-check.yml @@ -19,13 +19,11 @@ jobs: - name: Validate commit messages run: | - git log \ - --no-merges \ - --pretty=format:"%H" \ - "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" \ - | while IFS= read -r sha; do - tmp=$(mktemp) - git log -1 --pretty=format:"%B" "$sha" > "$tmp" - npx --yes @commitlint/cli@20.4.3 --edit "$tmp" || exit 1 - rm "$tmp" - done \ No newline at end of file + set -eo pipefail + commits=$(git log --no-merges --pretty=format:"%H" "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}") + for sha in $commits; do + tmp=$(mktemp) + git log -1 --pretty=format:"%B" "$sha" > "$tmp" + npx --yes @commitlint/cli@20.4.3 --edit "$tmp" + rm "$tmp" + done From ca51995aaec1c5cb08ea7d7da68215487f4229b7 Mon Sep 17 00:00:00 2001 From: KOPPIREDDY DURGA PRASAD <144464542+DurgaPrasad-54@users.noreply.github.com> Date: Fri, 6 Mar 2026 16:47:58 +0530 Subject: [PATCH 24/24] chore(commitlint): update commit-msg hook to use specific commitlint version --- .git-hooks/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.git-hooks/commit-msg b/.git-hooks/commit-msg index f27de35..63ea7d1 100644 --- a/.git-hooks/commit-msg +++ b/.git-hooks/commit-msg @@ -1,4 +1,4 @@ #!/bin/sh set -e -npx --yes @commitlint/cli --edit "$1" +npx --yes @commitlint/cli@20.4.3 --edit "$1"