fix signatures

This commit is contained in:
Kiril Videlov 2024-04-25 14:56:03 +02:00
parent 432aeeaf2a
commit b3c05b7948
3 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ pub struct SnapshotsReference {
} }
impl SnapshotsReference { impl SnapshotsReference {
pub fn new(project: Project, target_sha: &str) -> Result<Self> { pub fn new(project: &Project, target_sha: &str) -> Result<Self> {
let repo_path = project.path.as_path(); let repo_path = project.path.as_path();
let reflog_file_path = repo_path let reflog_file_path = repo_path
.join(".git") .join(".git")

View File

@ -13,7 +13,7 @@ pub struct SnapshotEntry {
pub created_at: i64, // milliseconds since epoch 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 { if let Some(false) = project.enable_snapshots {
return Ok(()); return Ok(());
} }
@ -55,7 +55,7 @@ pub fn create(project: Project, label: String) -> Result<()> {
None, None,
&signature, &signature,
&signature, &signature,
&label, label,
&tree, &tree,
&[&oplog_head_commit], &[&oplog_head_commit],
)?; )?;
@ -125,7 +125,7 @@ pub fn list(project: Project, limit: usize) -> Result<Vec<SnapshotEntry>> {
Ok(snapshots) 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_path = project.path.as_path();
let repo = git2::Repository::init(repo_path)?; let repo = git2::Repository::init(repo_path)?;
@ -149,7 +149,7 @@ pub fn restore(project: Project, sha: String) -> Result<()> {
"Restored from snapshot {}", "Restored from snapshot {}",
commit.message().unwrap_or(&sha) commit.message().unwrap_or(&sha)
); );
create(project, label)?; create(project, &label)?;
Ok(()) Ok(())
} }

View File

@ -32,6 +32,6 @@ pub async fn restore_snapshot(
.state::<projects::Controller>() .state::<projects::Controller>()
.get(&project_id) .get(&project_id)
.context("failed to get project")?; .context("failed to get project")?;
snapshot::restore(project, sha)?; snapshot::restore(&project, sha)?;
Ok(()) Ok(())
} }