mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-18 14:31:30 +03:00
Merge pull request #3733 from gitbutlerapp/make-snapshot-lines-threshold-optional
use default snapshot_lines_threshold
This commit is contained in:
commit
2df5ee0f7d
@ -87,12 +87,7 @@ pub struct Project {
|
||||
#[serde(default)]
|
||||
pub enable_snapshots: Option<bool>,
|
||||
// The number of changed lines that will trigger a snapshot
|
||||
#[serde(default = "default_snapshot_lines_threshold")]
|
||||
pub snapshot_lines_threshold: usize,
|
||||
}
|
||||
|
||||
fn default_snapshot_lines_threshold() -> usize {
|
||||
20
|
||||
pub snapshot_lines_threshold: Option<usize>,
|
||||
}
|
||||
|
||||
impl Project {
|
||||
@ -118,4 +113,8 @@ impl Project {
|
||||
pub fn virtual_branches(&self) -> VirtualBranchesHandle {
|
||||
VirtualBranchesHandle::new(self.gb_dir())
|
||||
}
|
||||
|
||||
pub fn snapshot_lines_threshold(&self) -> usize {
|
||||
self.snapshot_lines_threshold.unwrap_or(20)
|
||||
}
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ impl Handler {
|
||||
.get(&project_id)
|
||||
.context("failed to get project")?;
|
||||
let changed_lines = project.lines_since_snapshot()?;
|
||||
if changed_lines > project.snapshot_lines_threshold {
|
||||
if changed_lines > project.snapshot_lines_threshold() {
|
||||
project.create_snapshot(SnapshotDetails::new(OperationType::FileChanges))?;
|
||||
}
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user