HandleCommit commits dirty changes if required.
(ctx context.Context)
| 180 | |
| 181 | // HandleCommit commits dirty changes if required. |
| 182 | func (p Plugin) HandleCommit(ctx context.Context) error { |
| 183 | if p.Config.Commit { |
| 184 | if err := execute(repo.Add(ctx)); err != nil { |
| 185 | return err |
| 186 | } |
| 187 | |
| 188 | if err := execute(repo.TestCleanTree(ctx)); err != nil { |
| 189 | // changes to commit |
| 190 | if err := execute( |
| 191 | repo.ForceCommit( |
| 192 | ctx, |
| 193 | p.Config.CommitMessage, |
| 194 | p.Config.NoVerify, |
| 195 | p.Commit.Author.Name, |
| 196 | p.Commit.Author.Email, |
| 197 | ), |
| 198 | ); err != nil { |
| 199 | return err |
| 200 | } |
| 201 | } else { // no changes |
| 202 | if p.Config.EmptyCommit { |
| 203 | // no changes but commit anyway |
| 204 | if err := execute( |
| 205 | repo.EmptyCommit( |
| 206 | ctx, |
| 207 | p.Config.CommitMessage, |
| 208 | p.Config.NoVerify, |
| 209 | p.Commit.Author.Name, |
| 210 | p.Commit.Author.Email, |
| 211 | ), |
| 212 | ); err != nil { |
| 213 | return err |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | return nil |
| 220 | } |
| 221 | |
| 222 | // HandleTag add tag if required. |
| 223 | func (p Plugin) HandleTag(ctx context.Context) error { |
no test coverage detected