GithubHelp home page GithubHelp logo

Comments (3)

alexcrichton avatar alexcrichton commented on May 28, 2024

It looks like the problem here is that the pass variable passed in is None and you're calling .unwrap(). I believe this is just the password encoded in the URL, and it will be None if there wasn't one. If you use .unwrap_or(...) with a default password (or one learned from elsewhere), I think that'd do the trick!

from git2-rs.

k0pernicus avatar k0pernicus commented on May 28, 2024

Sorry for the delay.
I've update my code, and the program seems to loop...

This is my code:

match branch_back_up.as_mut() {
    Ok(branch) => match branch.set_upstream(Some("back_up")) {
        Ok(_) => println!("Branch 'back_up' has been updated!"),
        Err(error) => println!("Error due to {}", error),
    },
    Err(error) => panic!("Canno't upstream the branch 'back_up', due to error {}", error),
}
let refname = match branch_back_up.as_mut() {
    Ok(branch) => branch.get(),
    Err(error) => panic!("ERROR: {}", error),
};
// Find remote
let mut r_remote = r.find_remote("origin").unwrap();
// Push branch
let mut callbacks = RemoteCallbacks::new();
callbacks.credentials(|user, pass, ctype| {
    return Cred::userpass_plaintext(user, pass.unwrap_or("MY_PASSWORD"));
});
let mut push_options = PushOptions::new();
push_options.remote_callbacks(callbacks);
match r_remote.push(&[], Some(&mut push_options)) {
    Ok(_) => println!("Branch has been pushed!"),
    Err(error) => println!("Error {}", error),
};

but, since less 10 minutes, the program is blocked on

README.md has been added!
Branch 'back_up' has been updated!

Did I missed something? :-/

from git2-rs.

alexcrichton avatar alexcrichton commented on May 28, 2024

I think that you may have to specify some refs of what to push? I always forget what you precisely need to pass in, but it may help to see a working code example as well, although that doesn't deal with branches much as it only works with the master branch

from git2-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.