(repo *Repository, something, content string, commitOpts commitOptions)
| 472 | } |
| 473 | |
| 474 | func commitSomething(repo *Repository, something, content string, commitOpts commitOptions) (*Oid, error) { |
| 475 | headCommit, err := headCommit(repo) |
| 476 | if err != nil { |
| 477 | return nil, err |
| 478 | } |
| 479 | defer headCommit.Free() |
| 480 | |
| 481 | index, err := NewIndex() |
| 482 | if err != nil { |
| 483 | return nil, err |
| 484 | } |
| 485 | defer index.Free() |
| 486 | |
| 487 | blobOID, err := repo.CreateBlobFromBuffer([]byte(content)) |
| 488 | if err != nil { |
| 489 | return nil, err |
| 490 | } |
| 491 | |
| 492 | entry := &IndexEntry{ |
| 493 | Mode: FilemodeBlob, |
| 494 | Id: blobOID, |
| 495 | Path: something, |
| 496 | } |
| 497 | |
| 498 | if err := index.Add(entry); err != nil { |
| 499 | return nil, err |
| 500 | } |
| 501 | |
| 502 | newTreeOID, err := index.WriteTreeTo(repo) |
| 503 | if err != nil { |
| 504 | return nil, err |
| 505 | } |
| 506 | |
| 507 | newTree, err := repo.LookupTree(newTreeOID) |
| 508 | if err != nil { |
| 509 | return nil, err |
| 510 | } |
| 511 | defer newTree.Free() |
| 512 | |
| 513 | commit, err := repo.CreateCommit("HEAD", signature(), signature(), "Test rebase, Baby! "+something, newTree, headCommit) |
| 514 | if err != nil { |
| 515 | return nil, err |
| 516 | } |
| 517 | |
| 518 | if commitOpts.CommitSigningCallback != nil { |
| 519 | commit, err := repo.LookupCommit(commit) |
| 520 | if err != nil { |
| 521 | return nil, err |
| 522 | } |
| 523 | |
| 524 | oid, err := commit.WithSignatureUsing(commitOpts.CommitSigningCallback) |
| 525 | if err != nil { |
| 526 | return nil, err |
| 527 | } |
| 528 | newCommit, err := repo.LookupCommit(oid) |
| 529 | if err != nil { |
| 530 | return nil, err |
| 531 | } |
no test coverage detected
searching dependent graphs…