Skip to content

Commit

Permalink
Merge pull request k1LoW#215 from u-yas/feature/settings-commit-message
Browse files Browse the repository at this point in the history
feat: customize commit message by octocov.yml
  • Loading branch information
k1LoW authored Nov 11, 2022
2 parents e26f2b3 + 8d8393b commit 49650cc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,16 @@ push:

The variables available in the `if` section are [here](https://github.com/k1LoW/octocov#if).

### `push.message:`

message for commit.

``` yaml
# .octocov.yml
push:
message: Update by octocov [skip ci]
```

### `comment:`

Set this if want to comment report to pull request
Expand Down
16 changes: 14 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,13 @@ var rootCmd = &cobra.Command{
cmd.PrintErrf("Skip commit and push central report: %v\n", err)
} else {
cmd.PrintErrln("Commit and push central report")
if err := gh.PushUsingLocalGit(ctx, c.GitRoot, paths, "Update by octocov"); err != nil {

commitMessage := "Update by octocov"
if c.Central.Push.Message != "" {
commitMessage = c.Central.Push.Message
}

if err := gh.PushUsingLocalGit(ctx, c.GitRoot, paths, commitMessage); err != nil {
return err
}
}
Expand Down Expand Up @@ -443,7 +449,13 @@ var rootCmd = &cobra.Command{
cmd.PrintErrf("Skip pushing generate files: %v\n", err)
} else {
cmd.PrintErrln("Pushing generated files...")
if err := gh.PushUsingLocalGit(ctx, c.GitRoot, addPaths, "Update by octocov"); err != nil {

commitMessage := "Update by octocov"
if c.Push.Message != "" {
commitMessage = c.Push.Message
}

if err := gh.PushUsingLocalGit(ctx, c.GitRoot, addPaths, commitMessage); err != nil {
return err
}
}
Expand Down
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ type ConfigCentralBadges struct {
}

type ConfigPush struct {
If string `yaml:"if,omitempty"`
If string `yaml:"if,omitempty"`
Message string `yaml:"message,omitempty"`
}

type ConfigComment struct {
Expand Down
1 change: 1 addition & 0 deletions gh/gh.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ func PushUsingLocalGit(ctx context.Context, gitRoot string, addPaths []string, m
}

if !push {
fmt.Println("No files to be commit.")
return nil
}

Expand Down

0 comments on commit 49650cc

Please sign in to comment.