Skip to content

Commit

Permalink
fixed gitignore entry
Browse files Browse the repository at this point in the history
  • Loading branch information
jenna-a2ai committed Mar 27, 2024
1 parent 45718ae commit c1e75ff
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions dvs.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
storage_dir: /cluster-data/user-homes/jenna/Projects/devious/src/test_directory_storage
permissions: 500
group: datascience
7 changes: 4 additions & 3 deletions src/internal/git/ignore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand All @@ -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)?;
}
Expand Down
2 changes: 1 addition & 1 deletion src/internal/storage/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
};
Expand Down
8 changes: 8 additions & 0 deletions src/test_directory/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@


# Devious entry
/test1.txt


# Devious entry
/test2.txt
2 changes: 1 addition & 1 deletion src/test_directory/test1.txt.dvsmeta
Original file line number Diff line number Diff line change
@@ -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"}
{"file_hash":"71fe44583a6268b56139599c293aeb854e5c5a9908eca00105d81ad5e22b7bb6","file_size":445,"time_stamp":{"secs_since_epoch":1711556693,"nanos_since_epoch":62447111},"message":"derived DA files","saved_by":"jenna"}
2 changes: 1 addition & 1 deletion src/test_directory/test2.txt.dvsmeta
Original file line number Diff line number Diff line change
@@ -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"}
{"file_hash":"89f8cf7f7cb020264179262691755f9d9b6b2246cb61d9b43b057aba4cbfa1d0","file_size":25,"time_stamp":{"secs_since_epoch":1711556693,"nanos_since_epoch":62712978},"message":"derived DA files","saved_by":"jenna"}
Empty file.
Empty file.

0 comments on commit c1e75ff

Please sign in to comment.