diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/git.rs | 43 |
1 files changed, 19 insertions, 24 deletions
| @@ -558,7 +558,7 @@ impl RepoActions for Repo { | |||
| 558 | 558 | ||
| 559 | // let mut apply_opts = git2::ApplyOptions::new(); | 559 | // let mut apply_opts = git2::ApplyOptions::new(); |
| 560 | // apply_opts.check(false); | 560 | // apply_opts.check(false); |
| 561 | 561 | let mut existing_index = self.git_repo.index()?; | |
| 562 | let mut index = self.git_repo.apply_to_tree( | 562 | let mut index = self.git_repo.apply_to_tree( |
| 563 | &parent_tree, | 563 | &parent_tree, |
| 564 | &git2::Diff::from_buffer(patch.content.as_bytes())?, | 564 | &git2::Diff::from_buffer(patch.content.as_bytes())?, |
| @@ -579,29 +579,23 @@ impl RepoActions for Repo { | |||
| 579 | None | 579 | None |
| 580 | }; | 580 | }; |
| 581 | 581 | ||
| 582 | let mut applied_oid = if let Some(pgp_sig) = pgp_sig { | 582 | let commit_buff = self.git_repo.commit_create_buffer( |
| 583 | let commit_buff = self.git_repo.commit_create_buffer( | 583 | &extract_sig_from_patch_tags(&patch.tags, "author")?, |
| 584 | &extract_sig_from_patch_tags(&patch.tags, "author")?, | 584 | &extract_sig_from_patch_tags(&patch.tags, "committer")?, |
| 585 | &extract_sig_from_patch_tags(&patch.tags, "committer")?, | 585 | tag_value(patch, "description")?.as_str(), |
| 586 | tag_value(patch, "description")?.as_str(), | 586 | &tree, |
| 587 | &tree, | 587 | &[&parent_commit], |
| 588 | &[&parent_commit], | 588 | )?; |
| 589 | )?; | 589 | |
| 590 | self.git_repo | 590 | let mut applied_oid = self |
| 591 | .commit_signed(commit_buff.as_str().unwrap(), pgp_sig.as_str(), None) | 591 | .git_repo |
| 592 | .context("failed to create signed commit")? | 592 | .commit_signed( |
| 593 | } else { | 593 | commit_buff.as_str().unwrap(), |
| 594 | self.git_repo | 594 | pgp_sig.unwrap_or(String::new()).as_str(), |
| 595 | .commit( | 595 | None, |
| 596 | Some("HEAD"), | 596 | ) |
| 597 | &extract_sig_from_patch_tags(&patch.tags, "author")?, | 597 | .context("failed to create signed commit")?; |
| 598 | &extract_sig_from_patch_tags(&patch.tags, "committer")?, | 598 | |
| 599 | tag_value(patch, "description")?.as_str(), | ||
| 600 | &tree, | ||
| 601 | &[&parent_commit], | ||
| 602 | ) | ||
| 603 | .context("failed to create unsigned commit")? | ||
| 604 | }; | ||
| 605 | // I beleive this was added to address a bug where commit author / committer | 599 | // I beleive this was added to address a bug where commit author / committer |
| 606 | // were identical when in a scenario when they should be different but I dont | 600 | // were identical when in a scenario when they should be different but I dont |
| 607 | // think we have a test case for it. surely we should be using the | 601 | // think we have a test case for it. surely we should be using the |
| @@ -626,6 +620,7 @@ impl RepoActions for Repo { | |||
| 626 | get_commit_id_from_patch(patch)?, | 620 | get_commit_id_from_patch(patch)?, |
| 627 | ); | 621 | ); |
| 628 | } | 622 | } |
| 623 | self.git_repo.set_index(&mut existing_index)?; | ||
| 629 | Ok(applied_oid) | 624 | Ok(applied_oid) |
| 630 | } | 625 | } |
| 631 | fn parse_starting_commits(&self, starting_commits: &str) -> Result<Vec<Sha1Hash>> { | 626 | fn parse_starting_commits(&self, starting_commits: &str) -> Result<Vec<Sha1Hash>> { |