summaryrefslogtreecommitdiffstats
path: root/src/core/src/git.rs
blob: 315258fbaa3bf1299c4350129a81f37d6673363f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use std::sync::Arc;

use anyhow::Result;
use git::{CommitDiff, CommitDiffLoaderOptions, Repository};
use parking_lot::Mutex;

#[derive(Debug, Clone)]
pub(crate) struct Git {
	repository: Arc<Mutex<Repository>>,
}

impl Git {
	pub(crate) fn new(repository: Repository) -> Self {
		Self {
			repository: Arc::new(Mutex::new(repository)),
		}
	}

	pub(crate) fn load_commit_diff(&self, hash: &str, config: &CommitDiffLoaderOptions) -> Result<CommitDiff> {
		self.repository.lock().load_commit_diff(hash, config)
	}
}