Add support for creating signed commits and signing commits during a rebase #626

Merged
mbfr merged 25 commits from master into master 2020-08-18 11:25:31 -05:00
1 changed files with 9 additions and 17 deletions
Showing only changes of commit a08eb252c3 - Show all commits

View File

@ -38,12 +38,12 @@ func TestRebaseAbort(t *testing.T) {
seedTestRepo(t, repo) seedTestRepo(t, repo)
// Setup a repo with 2 branches and a different tree // Setup a repo with 2 branches and a different tree
err := setupRepoForRebase(repo, masterCommit, branchName) err := setupRepoForRebase(repo, masterCommit, branchName, commitOpts{})
checkFatal(t, err) checkFatal(t, err)
// Create several commits in emile // Create several commits in emile
for _, commit := range emileCommits { for _, commit := range emileCommits {
_, err = commitSomething(repo, commit, commit) _, err = commitSomething(repo, commit, commit, commitOpts{})
checkFatal(t, err) checkFatal(t, err)
} }
@ -99,12 +99,12 @@ func TestRebaseNoConflicts(t *testing.T) {
} }
// Setup a repo with 2 branches and a different tree // Setup a repo with 2 branches and a different tree
err = setupRepoForRebase(repo, masterCommit, branchName) err = setupRepoForRebase(repo, masterCommit, branchName, commitOpts{})
checkFatal(t, err) checkFatal(t, err)
// Create several commits in emile // Create several commits in emile
for _, commit := range emileCommits { for _, commit := range emileCommits {
_, err = commitSomething(repo, commit, commit) _, err = commitSomething(repo, commit, commit, commitOpts{})
checkFatal(t, err) checkFatal(t, err)
} }
@ -191,12 +191,12 @@ func TestRebaseGpgSigned(t *testing.T) {
} }
// Setup a repo with 2 branches and a different tree // Setup a repo with 2 branches and a different tree
err = setupRepoForRebaseOpts(repo, masterCommit, branchName, commitOpts) err = setupRepoForRebase(repo, masterCommit, branchName, commitOpts)
checkFatal(t, err) checkFatal(t, err)
// Create several commits in emile // Create several commits in emile
for _, commit := range emileCommits { for _, commit := range emileCommits {
_, err = commitSomethingOpts(repo, commit, commit, commitOpts) _, err = commitSomething(repo, commit, commit, commitOpts)
checkFatal(t, err) checkFatal(t, err)
} }
@ -255,11 +255,7 @@ func checkCommitSigned(t *testing.T, entity *openpgp.Entity, commit *Commit) err
} }
// Utils // Utils
func setupRepoForRebase(repo *Repository, masterCommit, branchName string) error { func setupRepoForRebase(repo *Repository, masterCommit, branchName string, opts commitOpts) error {
return setupRepoForRebaseOpts(repo, masterCommit, branchName, commitOpts{})
}
func setupRepoForRebaseOpts(repo *Repository, masterCommit, branchName string, opts commitOpts) error {
// Create a new branch from master // Create a new branch from master
err := createBranch(repo, branchName) err := createBranch(repo, branchName)
if err != nil { if err != nil {
@ -267,7 +263,7 @@ func setupRepoForRebaseOpts(repo *Repository, masterCommit, branchName string, o
} }
// Create a commit in master // Create a commit in master
_, err = commitSomethingOpts(repo, masterCommit, masterCommit, opts) _, err = commitSomething(repo, masterCommit, masterCommit, opts)
if err != nil { if err != nil {
return err return err
} }
@ -401,11 +397,7 @@ func headTree(repo *Repository) (*Tree, error) {
return tree, nil return tree, nil
} }
func commitSomething(repo *Repository, something, content string) (*Oid, error) { func commitSomething(repo *Repository, something, content string, commitOpts commitOpts) (*Oid, error) {
return commitSomethingOpts(repo, something, content, commitOpts{})
}
func commitSomethingOpts(repo *Repository, something, content string, commitOpts commitOpts) (*Oid, error) {
headCommit, err := headCommit(repo) headCommit, err := headCommit(repo)
if err != nil { if err != nil {
return nil, err return nil, err