Skip to content

Commit

Permalink
Use git2 v0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
hongquan committed Dec 1, 2023
1 parent 5a1fe45 commit 631b142
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
34 changes: 20 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "git-del-branches"
version = "0.3.0"
version = "0.4.0"
authors = ["Nguyễn Hồng Quân <[email protected]>"]
license = "GPL-3.0-or-later"
edition = "2021"
Expand All @@ -19,6 +19,6 @@ color-eyre = "0.6.2"
console = { version = "0.15.7", features = ["windows-console-colors"] }
eyre = "0.6.8"
format-bytes = "0.3.0"
git2 = "0.17.2"
git2_credentials = "0.12.0"
git2 = "0.18.1"
git2_credentials = "0.13.0"
inquire = "0.6.2"
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,22 @@ fn main() -> Result<()> {
let git_config = git2::Config::open_default()?;
let mut credential_handler = CredentialHandler::new(git_config);
remote_callback.credentials(move |url, username, allowed| {
let msg = if let Some(name) = username {
format!("Try authenticating with \"{}\" username for {}...", name, url)
} else {
format!("Try authenticating for {}, without username...", url)
};
eprintln!(" {}", style(msg).dim());
credential_handler.try_next_credential(url, username, allowed)
});
let mut origin = repo.find_remote("origin").ok();
let mut opts = PushOptions::new();
opts.remote_callbacks(remote_callback);
for (mut lb, rb) in branch_pairs {
lb.delete().ok();
if rb.is_some() && origin.is_some() {
delete_upstream_branch(rb.unwrap(), &mut origin.as_mut().unwrap(), &mut opts);
}
if let Some((orig, branch)) = origin.as_mut().zip(rb) {
delete_upstream_branch(branch, orig, &mut opts);
};
}
eprintln!("{} {}", Emoji("🎉", "v"), style("Done!").bright().green());
Ok(())
Expand Down

0 comments on commit 631b142

Please sign in to comment.