fn commit_and_push_to_remote(&self, repo: &Repository, index: &mut Index, signature: &Signature, id_refname: &str) -> Result<()> {

        // Create the new commit over the last one.
        let oid = index.write_tree()?;
        let tree = repo.find_tree(oid)?;
        let parent_commit = repo.head()?.resolve()?.peel(ObjectType::Commit)?.into_commit().unwrap();
        repo.commit(Some("HEAD"), &signature, &signature, "New Tip.", &tree, &[&parent_commit])?;

        // Prepare the connection.
        let mut remote = repo.find_remote(REMOTE_TEMP)?;
        let mut callbacks = RemoteCallbacks::new();
        callbacks.credentials(|_, _, _| Self::get_credentials());
        remote.connect_auth(Direction::Push, Some(callbacks), None)?;

        let mut push_options = PushOptions::new();
        let mut callbacks = RemoteCallbacks::new();
        let refspecs = format!("{}:{}", id_refname, id_refname);

        callbacks.credentials(|_, _, _| Self::get_credentials());
        push_options.remote_callbacks(callbacks);
        remote.push(&[&refspecs], Some(&mut push_options))?;

        Ok(())
    }
/// This function takes care of commiting changes and pushing them to the remote branch.
///
/// All branch-changing logic is out of this function!!!
This function takes care of commiting changes and pushing them to the remote branch.
All branch-changing logic is out of this function
This function takes care of commiting changes and pushing them to the remote branch . All branch - changing logic is out of this function
fn commit_and_push_to_remote(&self, repo: &Repository, index: &mut Index, signature: &Signature, id_refname: &str) -> Result<()> {
        // Create the new commit over the last one.
        let oid = index.write_tree()?;
        let tree = repo.find_tree(oid)?;
        let parent_commit = repo.head()?.resolve()?.peel(ObjectType::Commit)?.into_commit().unwrap();
        repo.commit(Some("HEAD"), &signature, &signature, "New Tip.", &tree, &[&parent_commit])?;
        // Prepare the connection.
        let mut remote = repo.find_remote(REMOTE_TEMP)?;
        let mut callbacks = RemoteCallbacks::new();
        callbacks.credentials(|_, _, _| Self::get_credentials());
        remote.connect_auth(Direction::Push, Some(callbacks), None)?;
        let mut push_options = PushOptions::new();
        let mut callbacks = RemoteCallbacks::new();
        let refspecs = format!("{}:{}", id_refname, id_refname);
        callbacks.credentials(|_, _, _| Self::get_credentials());
        push_options.remote_callbacks(callbacks);
        remote.push(&[&refspecs], Some(&mut push_options))?;
        Ok(())
    }
fn commit_and_push_to_remote ( & self , repo : & Repository , index : & mut Index , signature : & Signature , id_refname : & str ) -> Result < ( ) > { // Create the new commit over the last one. let oid = index . write_tree ( ) ? ; let tree = repo . find_tree ( oid ) ? ; let parent_commit = repo . head ( ) ? . resolve ( ) ? . peel ( ObjectType :: Commit ) ? . into_commit ( ) . unwrap ( ) ; repo . commit ( Some ( " " ) , & signature , & signature , " " , & tree , & [ & parent_commit ] ) ? ; // Prepare the connection. let mut remote = repo . find_remote ( REMOTE_TEMP ) ? ; let mut callbacks = RemoteCallbacks :: new ( ) ; callbacks . credentials ( | _ , _ , _ | Self :: get_credentials ( ) ) ; remote . connect_auth ( Direction :: Push , Some ( callbacks ) , None ) ? ; let mut push_options = PushOptions :: new ( ) ; let mut callbacks = RemoteCallbacks :: new ( ) ; let refspecs = format ! ( " " id_refname id_refname ) ; callbacks . credentials ( | _ , _ , _ | Self :: get_credentials ( ) ) ; push_options . remote_callbacks ( callbacks ) ; remote . push ( & [ & refspecs ] , Some ( & mut push_options ) ) ? ; Ok ( ( ) ) }
This function takes care of commiting changes and pushing them to the remote branch.
This function takes care of commiting changes and pushing them to the remote branch .
&self
repo
&Repository
index
&mut Index
signature
&Signature
id_refname
&str
&self
repo
&Repository
index
&mut Index
signature
&Signature
id_refname
&str