Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The result: for example, if the branch name is `312-improve-stability-of-the-cor
> #312: Refactor core service initialization logic
### Configuration
By default, the tool recognizes the pattern suggested by GitHub when auto-generating branches, when issue numbers are just digits: `28-update-documentation` for the issue `#28`.
But this can be changed by setting different values in a `.commit.json` file at the root of your repository:
But this can be changed by providing a `.commit.json` file with different values at the root of your repository:
```json
{
"issueRegex": "ABC-[0-9]+",
Expand All @@ -79,8 +79,7 @@ The structure of the resulting commit message is as follows:
```
<outputStringPrefix><outputIssuePrefix><issueRegex><outputIssueSuffix>, <outputIssuePrefix><issueRegex><outputIssueSuffix><outputStringSuffix> <commit message>
```
If the `.commit.json` file is not included, the tool will just fall back to its default settings (GitHub style issues).
Same will happen for any of the settings that is not included in the config json. See the default values in [constants.go](/internal/helpers/constants.go) file.
If the `.commit.json` file is not included, the tool will just fall back to its default settings (GitHub style issues). See the default values in [constants.go](/internal/helpers/constants.go) file.
### Custom Config Path
If you don't want to include the `.commit.json` file at the root of your repository, path to the config file can be passed with a `-config-path` flag like this (linux/macOS shell example):
```shell
Expand Down
9 changes: 8 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,12 @@ func MakeDefaultConfig() CommitConfig {
// MARK: - Private

func makeConfig(cfgDto commitConfigDTO) CommitConfig {
cfg := MakeDefaultConfig()
cfg := CommitConfig{}

if cfgDto.IssueRegex != nil {
if *cfgDto.IssueRegex == "" {
return cfg
}
cfg.IssueRegex = *cfgDto.IssueRegex
}

Expand All @@ -89,6 +92,10 @@ func makeConfig(cfgDto commitConfigDTO) CommitConfig {
cfg.OutputStringSuffix = *cfgDto.OutputStringSuffix
}

if (cfg == CommitConfig{}) {
return MakeDefaultConfig()
}

return cfg
}

Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func Test_ReadCommitConfig_WhenOnlyRegexInConfix_ReturnsConfigWithRegex(t *testi
configJson := fmt.Sprintf("{\"issueRegex\":\"%s\"}", expectedRegex)
mock.Results.ReadFile.Success = []byte(configJson)

expectedConfig := config.MakeDefaultConfig()
expectedConfig := config.CommitConfig{}
expectedConfig.IssueRegex = expectedRegex

// Act
Expand Down
Loading