Skip to content

Commit 3769f40

Browse files
committed
improve checkout to look for config file in root directory
1 parent 43a0a79 commit 3769f40

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ commit
4141
## Config file
4242

4343
You can add a config file to project directory `.git-commands.json` to override the default values.
44+
Alternatively, you can add a global config file to your home directory `~/.git-commands.json`.
4445

4546
```json
4647
{

cmd/checkout/config.go

+8
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ func loadConfig() ([]list.Item, []list.Item, error) {
8484
}
8585
for {
8686
rel, _ := filepath.Rel(basePath, targetPath)
87+
fmt.Println("Rel:", rel)
8788
if rel == "." {
89+
filePath := filepath.Join(basePath, configFile)
90+
if _, err := os.Open(filePath); err == nil {
91+
fmt.Println("Found config file at", filePath)
92+
return loadConfigFile(filePath)
93+
}
8894
break
8995
}
9096
filePath := filepath.Join(targetPath, configFile)
@@ -93,6 +99,8 @@ func loadConfig() ([]list.Item, []list.Item, error) {
9399
return loadConfigFile(filePath)
94100
}
95101

102+
fmt.Println("No config file found at", filePath)
103+
96104
targetPath += "/.."
97105
}
98106
fmt.Println("No config file found, using default config")

0 commit comments

Comments
 (0)