Skip to content

Commit 820e9b0

Browse files
author
isuke
committed
feat: change file name from .git_consistent to .git_consistent.yaml
`.git_consistent` file has been replaced by `.git_consistent.yaml`, while the legacy extension-less file remains fully supported.
1 parent f2cd04f commit 820e9b0

4 files changed

Lines changed: 30 additions & 14 deletions

File tree

File renamed without changes.

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ It is intended to be read by both human contributors and AI assistants.
2323
- Main tech stack:
2424
- Node.js ESM (`"type": "module"`)
2525
- CLI: `commander`, `inquirer`, `prompt-sync`
26-
- Configuration: `.git_consistent` (YAML) and `.gitcommit_template`
26+
- Configuration: `.git_consistent.yaml` (YAML) and `.gitcommit_template`
2727
- Tests: `ava`
2828
- Lint / formatting: `eslint` + `prettier`
2929

3030
**Key files / directories**
3131

3232
- `lib/` – CLI implementation
33-
- `.git_consistent` – sample configuration for user projects
33+
- `.git_consistent.yaml` – sample configuration for user projects
3434
- `.gitcommit_template` – commit template
3535
- `test/` – AVA tests
3636
- `.github/workflows/main.yml` – CI (lint + test)
@@ -63,7 +63,7 @@ It is intended to be read by both human contributors and AI assistants.
6363

6464
---
6565

66-
## 5. `.git_consistent` and `.gitcommit_template`
66+
## 5. `.git_consistent.yaml` and `.gitcommit_template`
6767

6868
- These files directly affect users’ commit workflows, so **prioritize compatibility and clarity**.
6969
- When changing samples:

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Supported Node.js versions:
2323
## Features
2424

2525
- **Interactive & Inline Modes**: Create commits interactively or directly from the command line.
26-
- **Customizable Commit Format**: Define your own commit message structure with a simple YAML configuration file (`.git_consistent`).
26+
- **Customizable Commit Format**: Define your own commit message structure with a simple YAML configuration file (`.git_consistent.yaml`).
2727
- **Validation Rules**: Enforce standards like case rules for the subject, character limits, and more.
2828
- **Dynamic Variables**: Automatically insert values like issue numbers into your commit messages.
2929
- **Branch Name Parsing**: Extract information (e.g., issue IDs) directly from your git branch name.
@@ -69,7 +69,7 @@ git consistent --init
6969
```
7070

7171
This will ask you a few questions and generate two files:
72-
- `.git_consistent`: Your configuration file.
72+
- `.git_consistent.yaml`: Your configuration file.
7373
- `.gitcommit_template`: The template for your commit messages.
7474

7575
Feel free to edit these files to match your project's conventions.
@@ -107,9 +107,9 @@ Provide all the information using command-line flags.
107107
git consistent --type="feat" --subject="implement new feature" --body="This is an amazing feature."
108108
```
109109

110-
## Configuration (`.git_consistent`)
110+
## Configuration (`.git_consistent.yaml`)
111111

112-
The `.git_consistent` file allows you to define and customize the structure of your commit messages. It uses a simple YAML-like format.
112+
The `.git_consistent.yaml` file allows you to define and customize the structure of your commit messages. It uses a simple YAML-like format.
113113

114114
Here is the basic structure:
115115

@@ -192,7 +192,7 @@ Create a `githubIssueUrl` variable based on a `githubIssueNum` input.
192192
<body>
193193
```
194194
195-
**`.git_consistent`:**
195+
**`.git_consistent.yaml`:**
196196
```yml
197197
githubIssueNum:
198198
type: string
@@ -242,7 +242,7 @@ Automatically generate an issue link from a branch name like `issue/123-feature-
242242
<body>
243243
```
244244

245-
**`.git_consistent`:**
245+
**`.git_consistent.yaml`:**
246246
```yml
247247
issueLink:
248248
type: branch

lib/index.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ import genConfig from './gen-config.js'
1515
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
1616

1717
const templateFileName = '.gitcommit_template'
18-
const definitionsFileName = '.git_consistent'
18+
const definitionsFileName = '.git_consistent.yaml'
19+
const definitionsFileNameCandidates = [
20+
'.git_consistent.yaml',
21+
'.git_consistent.yml',
22+
'.git_consistent',
23+
'git_consistent.yaml',
24+
'git_consistent.yml',
25+
'git_consistent',
26+
]
1927

2028
const program = new Command()
2129

@@ -33,10 +41,18 @@ const getGitProjectRootPath = () => {
3341
}
3442
}
3543

36-
const getFilePath = (filePaths, fileName) => {
37-
const filePath = filePaths.find((filePath) => fs.existsSync(path.join(filePath, fileName)))
44+
const getFilePath = (filePaths, fileNames) => {
45+
const candidates = Array.isArray(fileNames) ? fileNames : [fileNames]
3846

39-
return filePath ? path.join(filePath, fileName) : undefined
47+
for (const basePath of filePaths) {
48+
if (!basePath) continue
49+
for (const name of candidates) {
50+
const fullPath = path.join(basePath, name)
51+
if (fs.existsSync(fullPath)) return fullPath
52+
}
53+
}
54+
55+
return undefined
4056
}
4157

4258
const loadYaml = (path) => {
@@ -88,7 +104,7 @@ const runHelp = (program, definitionsFilePath) => {
88104
//
89105
const rootPath = getGitProjectRootPath() || '.'
90106
const templateFilePath = getFilePath([rootPath, process.env.HOME], templateFileName)
91-
const definitionsFilePath = getFilePath([rootPath, process.env.HOME], definitionsFileName)
107+
const definitionsFilePath = getFilePath([rootPath, process.env.HOME], definitionsFileNameCandidates)
92108

93109
program
94110
.option('-d, --duet', 'run git-duet mode')

0 commit comments

Comments
 (0)