MCPcopy Create free account
hub / github.com/appleboy/drone-git-push / HandleCommit

Method HandleCommit

plugin.go:182–220  ·  view source on GitHub ↗

HandleCommit commits dirty changes if required.

(ctx context.Context)

Source from the content-addressed store, hash-verified

180
181// HandleCommit commits dirty changes if required.
182func (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.
223func (p Plugin) HandleTag(ctx context.Context) error {

Callers 1

ExecMethod · 0.95

Calls 5

AddFunction · 0.92
TestCleanTreeFunction · 0.92
ForceCommitFunction · 0.92
EmptyCommitFunction · 0.92
executeFunction · 0.85

Tested by

no test coverage detected