Skip to content

Commit b6cd415

Browse files
committed
refactor: git2 repository can now be owned by the Repo type
Previously this wasn't possible as commits would be kept in `Repo` which would cause self-referential borrow check issues unless the git2 repository was kept outside.
1 parent 7b34b0a commit b6cd415

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/info/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl Info {
184184
}
185185
});
186186

187-
let repo = Repo::new(&repo)?;
187+
let repo = Repo::new(repo)?;
188188
let mut commits = Commits::new(
189189
repo.gitoxide(),
190190
config.no_merges,
@@ -197,13 +197,14 @@ impl Info {
197197
let git_username = repo.get_git_username()?;
198198
let number_of_tags = repo.get_number_of_tags()?;
199199
let number_of_branches = repo.get_number_of_branches()?;
200+
let (repo_size, file_count) = repo.get_repo_size();
201+
let license = Detector::new()?.get_license(&workdir)?;
202+
let dependencies = DependencyDetector::new().get_dependencies(&workdir)?;
203+
200204
let creation_date = commits.get_creation_date(config.iso_time);
201205
let number_of_commits = commits.count();
202206
let (authors, contributors) = commits.take_authors(config.show_email);
203207
let last_change = commits.get_date_of_last_commit(config.iso_time);
204-
let (repo_size, file_count) = repo.get_repo_size();
205-
let license = Detector::new()?.get_license(&workdir)?;
206-
let dependencies = DependencyDetector::new().get_dependencies(&workdir)?;
207208

208209
let pending_changes = pending_changes
209210
.join()

src/info/repo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ pub struct Commits {
2323
time_of_first_commit: git::actor::Time,
2424
}
2525

26-
pub struct Repo<'a> {
27-
git2_repo: &'a Repository,
26+
pub struct Repo {
27+
git2_repo: Repository,
2828
repo: git::Repository,
2929
}
3030

@@ -153,8 +153,8 @@ impl Commits {
153153
}
154154
}
155155

156-
impl<'a> Repo<'a> {
157-
pub fn new(git2_repo: &'a Repository) -> Result<Self> {
156+
impl Repo {
157+
pub fn new(git2_repo: Repository) -> Result<Self> {
158158
let repo = git::open(git2_repo.path())?;
159159

160160
Ok(Self { repo, git2_repo })

0 commit comments

Comments
 (0)