From c1e75ffac358de997bedbb6806b40749491f06d4 Mon Sep 17 00:00:00 2001 From: Jenna Elwing Date: Wed, 27 Mar 2024 12:26:26 -0400 Subject: [PATCH] fixed gitignore entry --- dvs.yaml | 2 ++ src/internal/git/ignore.rs | 7 ++++--- src/internal/storage/add.rs | 2 +- src/test_directory/.gitignore | 8 ++++++++ src/test_directory/test1.txt.dvsmeta | 2 +- src/test_directory/test2.txt.dvsmeta | 2 +- ...6268b56139599c293aeb854e5c5a9908eca00105d81ad5e22b7bb6 | 0 ...b020264179262691755f9d9b6b2246cb61d9b43b057aba4cbfa1d0 | 0 8 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 src/test_directory/.gitignore mode change 100644 => 100755 src/test_directory_storage/71/fe44583a6268b56139599c293aeb854e5c5a9908eca00105d81ad5e22b7bb6 mode change 100644 => 100755 src/test_directory_storage/89/f8cf7f7cb020264179262691755f9d9b6b2246cb61d9b43b057aba4cbfa1d0 diff --git a/dvs.yaml b/dvs.yaml index 37aa7fc..0192bad 100644 --- a/dvs.yaml +++ b/dvs.yaml @@ -1 +1,3 @@ storage_dir: /cluster-data/user-homes/jenna/Projects/devious/src/test_directory_storage +permissions: 500 +group: datascience diff --git a/src/internal/git/ignore.rs b/src/internal/git/ignore.rs index 8621193..24dadaf 100644 --- a/src/internal/git/ignore.rs +++ b/src/internal/git/ignore.rs @@ -2,9 +2,10 @@ use std::{fs::{File, OpenOptions}, path::PathBuf}; use crate::internal::git::repo; use std::io::prelude::*; -pub fn add_gitignore_entry(git_dir: &PathBuf, path: &PathBuf) -> Result<(), std::io::Error> { +pub fn add_gitignore_entry(path: &PathBuf) -> Result<(), std::io::Error> { + let dir = path.parent().unwrap().to_path_buf(); // get relative path - let ignore_entry_temp = match repo::get_relative_path(git_dir, path) { + let ignore_entry_temp = match repo::get_relative_path(&dir, path) { Ok(entry) => entry, Err(e) => return Err(e) }; @@ -13,7 +14,7 @@ pub fn add_gitignore_entry(git_dir: &PathBuf, path: &PathBuf) -> Result<(), std: let ignore_entry = format!("/{path}"); // open the gitignore file, creating one if it doesn't exist - let ignore_file = git_dir.join(".gitignore"); + let ignore_file = dir.join(".gitignore"); if !ignore_file.exists() { File::create(&ignore_file)?; } diff --git a/src/internal/storage/add.rs b/src/internal/storage/add.rs index b1e7500..76b4a13 100644 --- a/src/internal/storage/add.rs +++ b/src/internal/storage/add.rs @@ -109,7 +109,7 @@ pub fn add(local_path: &PathBuf, conf: &Config, git_dir: &PathBuf, message: &Str }; // Add file to gitignore - match ignore::add_gitignore_entry(git_dir, local_path) { + match ignore::add_gitignore_entry(local_path) { Ok(_) => {}, Err(_) => return Err(std::io::Error::other("gitignore entry could not be created")) }; diff --git a/src/test_directory/.gitignore b/src/test_directory/.gitignore new file mode 100644 index 0000000..6f36a06 --- /dev/null +++ b/src/test_directory/.gitignore @@ -0,0 +1,8 @@ + + +# Devious entry +/test1.txt + + +# Devious entry +/test2.txt diff --git a/src/test_directory/test1.txt.dvsmeta b/src/test_directory/test1.txt.dvsmeta index 5e868a8..313fbc3 100644 --- a/src/test_directory/test1.txt.dvsmeta +++ b/src/test_directory/test1.txt.dvsmeta @@ -1 +1 @@ -{"file_hash":"71fe44583a6268b56139599c293aeb854e5c5a9908eca00105d81ad5e22b7bb6","file_size":445,"time_stamp":{"secs_since_epoch":1711549478,"nanos_since_epoch":814808013},"message":"derived DA files","group":"datascience","saved_by":"jenna"} \ No newline at end of file +{"file_hash":"71fe44583a6268b56139599c293aeb854e5c5a9908eca00105d81ad5e22b7bb6","file_size":445,"time_stamp":{"secs_since_epoch":1711556693,"nanos_since_epoch":62447111},"message":"derived DA files","saved_by":"jenna"} \ No newline at end of file diff --git a/src/test_directory/test2.txt.dvsmeta b/src/test_directory/test2.txt.dvsmeta index 2c3929c..24e9424 100644 --- a/src/test_directory/test2.txt.dvsmeta +++ b/src/test_directory/test2.txt.dvsmeta @@ -1 +1 @@ -{"file_hash":"89f8cf7f7cb020264179262691755f9d9b6b2246cb61d9b43b057aba4cbfa1d0","file_size":25,"time_stamp":{"secs_since_epoch":1711549396,"nanos_since_epoch":217722251},"message":"derived DA files","group":"datascience","saved_by":"jenna"} \ No newline at end of file +{"file_hash":"89f8cf7f7cb020264179262691755f9d9b6b2246cb61d9b43b057aba4cbfa1d0","file_size":25,"time_stamp":{"secs_since_epoch":1711556693,"nanos_since_epoch":62712978},"message":"derived DA files","saved_by":"jenna"} \ No newline at end of file diff --git a/src/test_directory_storage/71/fe44583a6268b56139599c293aeb854e5c5a9908eca00105d81ad5e22b7bb6 b/src/test_directory_storage/71/fe44583a6268b56139599c293aeb854e5c5a9908eca00105d81ad5e22b7bb6 old mode 100644 new mode 100755 diff --git a/src/test_directory_storage/89/f8cf7f7cb020264179262691755f9d9b6b2246cb61d9b43b057aba4cbfa1d0 b/src/test_directory_storage/89/f8cf7f7cb020264179262691755f9d9b6b2246cb61d9b43b057aba4cbfa1d0 old mode 100644 new mode 100755