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)]
|
#[serde(default)]
|
||||||
pub enable_snapshots: Option<bool>,
|
pub enable_snapshots: Option<bool>,
|
||||||
// The number of changed lines that will trigger a snapshot
|
// The number of changed lines that will trigger a snapshot
|
||||||
#[serde(default = "default_snapshot_lines_threshold")]
|
pub snapshot_lines_threshold: Option<usize>,
|
||||||
pub snapshot_lines_threshold: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_snapshot_lines_threshold() -> usize {
|
|
||||||
20
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Project {
|
impl Project {
|
||||||
@ -118,4 +113,8 @@ impl Project {
|
|||||||
pub fn virtual_branches(&self) -> VirtualBranchesHandle {
|
pub fn virtual_branches(&self) -> VirtualBranchesHandle {
|
||||||
VirtualBranchesHandle::new(self.gb_dir())
|
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)
|
.get(&project_id)
|
||||||
.context("failed to get project")?;
|
.context("failed to get project")?;
|
||||||
let changed_lines = project.lines_since_snapshot()?;
|
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))?;
|
project.create_snapshot(SnapshotDetails::new(OperationType::FileChanges))?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user