From b3c05b794861a957322241b365cfde8b0737e6dc Mon Sep 17 00:00:00 2001 From: Kiril Videlov Date: Thu, 25 Apr 2024 14:56:03 +0200 Subject: [PATCH] fix signatures --- crates/gitbutler-core/src/snapshots/reflog.rs | 2 +- crates/gitbutler-core/src/snapshots/snapshot.rs | 8 ++++---- crates/gitbutler-tauri/src/snapshots.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/gitbutler-core/src/snapshots/reflog.rs b/crates/gitbutler-core/src/snapshots/reflog.rs index 15fa314f9..024e66504 100644 --- a/crates/gitbutler-core/src/snapshots/reflog.rs +++ b/crates/gitbutler-core/src/snapshots/reflog.rs @@ -11,7 +11,7 @@ pub struct SnapshotsReference { } impl SnapshotsReference { - pub fn new(project: Project, target_sha: &str) -> Result { + pub fn new(project: &Project, target_sha: &str) -> Result { let repo_path = project.path.as_path(); let reflog_file_path = repo_path .join(".git") diff --git a/crates/gitbutler-core/src/snapshots/snapshot.rs b/crates/gitbutler-core/src/snapshots/snapshot.rs index 875a96c3b..9f1514cda 100644 --- a/crates/gitbutler-core/src/snapshots/snapshot.rs +++ b/crates/gitbutler-core/src/snapshots/snapshot.rs @@ -13,7 +13,7 @@ pub struct SnapshotEntry { pub created_at: i64, // milliseconds since epoch } -pub fn create(project: Project, label: String) -> Result<()> { +pub fn create(project: &Project, label: &str) -> Result<()> { if let Some(false) = project.enable_snapshots { return Ok(()); } @@ -55,7 +55,7 @@ pub fn create(project: Project, label: String) -> Result<()> { None, &signature, &signature, - &label, + label, &tree, &[&oplog_head_commit], )?; @@ -125,7 +125,7 @@ pub fn list(project: Project, limit: usize) -> Result> { Ok(snapshots) } -pub fn restore(project: Project, sha: String) -> Result<()> { +pub fn restore(project: &Project, sha: String) -> Result<()> { let repo_path = project.path.as_path(); let repo = git2::Repository::init(repo_path)?; @@ -149,7 +149,7 @@ pub fn restore(project: Project, sha: String) -> Result<()> { "Restored from snapshot {}", commit.message().unwrap_or(&sha) ); - create(project, label)?; + create(project, &label)?; Ok(()) } diff --git a/crates/gitbutler-tauri/src/snapshots.rs b/crates/gitbutler-tauri/src/snapshots.rs index 3251c95c6..8cc0977fe 100644 --- a/crates/gitbutler-tauri/src/snapshots.rs +++ b/crates/gitbutler-tauri/src/snapshots.rs @@ -32,6 +32,6 @@ pub async fn restore_snapshot( .state::() .get(&project_id) .context("failed to get project")?; - snapshot::restore(project, sha)?; + snapshot::restore(&project, sha)?; Ok(()) }