pub fn apply_commit(&self, target: &Repository) -> Result<(), git2::Error> {
          target.apply(&self.diff, ApplyLocation::Both, None)?;
          let time = git2::Time::new(
               self.date.timestamp(),
               // seconds -> minutes
               self.date.timezone().local_minus_utc() / 60
          );
          let author = Signature::new(
               &self.author_name,
               &self.author_email,
               &time
          )?;
          let tree = target.index()?.write_tree_to(target)?;
          let tree = target.find_tree(tree)?;
          // TODO: Handle detatched head/no commits
          let head_commit = target.head()?.peel_to_commit()?;
          let parents = vec![&head_commit];
          let message = self.full_message();
          target.commit(
               Some("HEAD"),
               &author,
               &author,
               &message,
               &tree,
               &parents
          )?;
          Ok(())
     }
/// Apply this email as a new commit against the repo
Apply this email as a new commit against the repo
Apply this email as a new commit against the repo
pub fn apply_commit(&self, target: &Repository) -> Result<(), git2::Error> {
          target.apply(&self.diff, ApplyLocation::Both, None)?;
          let time = git2::Time::new(
               self.date.timestamp(),
               // seconds -> minutes
               self.date.timezone().local_minus_utc() / 60
          );
          let author = Signature::new(
               &self.author_name,
               &self.author_email,
               &time
          )?;
          let tree = target.index()?.write_tree_to(target)?;
          let tree = target.find_tree(tree)?;
          // TODO: Handle detatched head/no commits
          let head_commit = target.head()?.peel_to_commit()?;
          let parents = vec![&head_commit];
          let message = self.full_message();
          target.commit(
               Some("HEAD"),
               &author,
               &author,
               &message,
               &tree,
               &parents
          )?;
          Ok(())
     }
pub fn apply_commit ( & self , target : & Repository ) -> Result < ( ) , git2 :: Error > { target . apply ( & self . diff , ApplyLocation :: Both , None ) ? ; let time = git2 :: Time :: new ( self . date . timestamp ( ) , // seconds -> minutes self . date . timezone ( ) . local_minus_utc ( ) / 60 ) ; let author = Signature :: new ( & self . author_name , & self . author_email , & time ) ? ; let tree = target . index ( ) ? . write_tree_to ( target ) ? ; let tree = target . find_tree ( tree ) ? ; // TODO: Handle detatched head/no commits let head_commit = target . head ( ) ? . peel_to_commit ( ) ? ; let parents = vec ! [ head_commit ] ; let message = self . full_message ( ) ; target . commit ( Some ( " " ) , & author , & author , & message , & tree , & parents ) ? ; Ok ( ( ) ) }
Apply this email as a new commit against the repo
Apply this email as a new commit against the repo
&self
target
&Repository