Skip to content

Commit 615e071

Browse files
committed
Retrieve all branches with gitoxide
1 parent c42a1ef commit 615e071

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Diff for: src/info/repo.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::info::author::Author;
22
use crate::info::head_refs::HeadRefs;
33
use anyhow::{Context, Result};
44
use byte_unit::Byte;
5-
use git2::{BranchType, Repository, RepositoryOpenFlags, Status, StatusOptions, StatusShow};
5+
use git2::{Repository, RepositoryOpenFlags, Status, StatusOptions, StatusShow};
66
use git_repository as git;
77
use git_repository::bstr::ByteSlice;
88
use regex::Regex;
@@ -50,8 +50,12 @@ impl<'a> Repo<'a> {
5050

5151
let mut time_of_most_recent_commit = None;
5252
let mut time_of_first_commit = None;
53-
let mut ancestors = repo.head()?.peel_to_commit_in_place()?.ancestors();
54-
let mut commit_iter = ancestors.all().peekable();
53+
let mut commit_iter = repo
54+
.head()?
55+
.peel_to_commit_in_place()?
56+
.ancestors()
57+
.all()
58+
.peekable();
5559

5660
let mailmap = repo.load_mailmap();
5761
let mut author_to_number_of_commits: HashMap<Sig, usize> = HashMap::new();
@@ -166,7 +170,7 @@ impl<'a> Repo<'a> {
166170
}
167171

168172
pub fn get_number_of_branches(&self) -> Result<usize> {
169-
let mut number_of_branches = self.git2_repo.branches(Some(BranchType::Remote))?.count();
173+
let mut number_of_branches = self.repo.references()?.remote_branches()?.count();
170174
if number_of_branches > 0 {
171175
//Exclude origin/HEAD -> origin/main
172176
number_of_branches -= 1;
@@ -320,8 +324,8 @@ impl<'a> Repo<'a> {
320324
}
321325

322326
fn work_dir(&self) -> Result<&Path> {
323-
self.git2_repo
324-
.workdir()
327+
self.repo
328+
.work_dir()
325329
.with_context(|| "unable to query workdir")
326330
}
327331
}

0 commit comments

Comments
 (0)