Merge pull request #3733 from gitbutlerapp/make-snapshot-lines-threshold-optional

use default snapshot_lines_threshold
This commit is contained in:
Kiril Videlov 2024-05-08 03:11:13 +02:00 committed by GitHub
commit 2df5ee0f7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 7 deletions

View File

@ -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)
}
}

View File

@ -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(())