Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
jenna-a2ai committed Mar 28, 2024
1 parent a621f17 commit 88dc84a
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 67 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ memmap2 = "0.7.1"
rayon = "1.7.0"
file-owner = "0.1.2"
chrono = "0.4.37"
walkdir = "2.4.0"
walkdir = "2.4.0"
path-absolutize = "3.1.1"
20 changes: 2 additions & 18 deletions src/cmd/status_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::path::PathBuf;

use crate::internal::config::config;
use crate::internal::file::hash;
use crate::internal::git::{self, repo};
use crate::internal::log::json;
use crate::internal::git::repo;
use crate::internal::meta::{file, parse};

#[derive(Debug)]
Expand All @@ -17,28 +16,13 @@ pub struct JsonFileResult {
pub message: String
}

// struct JsonResult {
// files: Vec<JsonFileResult>,
// errors:Vec<json::JsonIssue>
// }

// impl JsonResult {
// fn add_file(&mut self, file_result: JsonFileResult) {
// self.files.push(file_result);
// }

// fn add_error(&mut self, json_issue: json::JsonIssue) {
// self.errors.push(json_issue);
// }
// } // impl

pub fn run_status_cmd(files: &Vec<String>) -> Result<Vec<JsonFileResult>, std::io::Error> {

let mut json_logger: Vec<JsonFileResult> = Vec::new();

let mut meta_paths: Vec<PathBuf> = Vec::new();

//iIf no arguments are provided, get the status of all files in the current git repository
// if no arguments are provided, get the status of all files in the current git repository
if files.is_empty() {
// Get git root
let git_repo = match repo::get_nearest_repo_dir(&PathBuf::from(".")) {
Expand Down
10 changes: 5 additions & 5 deletions src/internal/git/repo.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use std::path::{PathBuf, Path};
use std::fs;
use path_absolutize::*;

pub fn get_relative_path(root_dir: &PathBuf, file_path: &PathBuf) -> Result<PathBuf, std::io::Error> {
// let abs_file_path = match file_path.canonicalize() {
// Ok(path) => path,
// Err(e) => return Err(e),
// };
let abs_file_string = file_path.absolutize().unwrap().to_str().unwrap().to_string();
let abs_file_path = PathBuf::from(abs_file_string);


let abs_root_dir = match root_dir.canonicalize() {
Ok(path) => path,
Err(e) => return Err(e),
};

match file_path.strip_prefix(abs_root_dir) {
match abs_file_path.strip_prefix(abs_root_dir) {
Ok(path) => return Ok(path.to_path_buf()),
Err(_) => return Err(std::io::Error::other("paths not relative")),
}
Expand Down
31 changes: 0 additions & 31 deletions src/internal/log/json.rs

This file was deleted.

2 changes: 0 additions & 2 deletions src/internal/log/mod.rs

This file was deleted.

7 changes: 0 additions & 7 deletions src/internal/log/pretty.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/internal/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod config;
pub mod file;
pub mod git;
pub mod log;
pub mod meta;
pub mod migrate;
pub mod storage;
Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ fn main() -> io::Result<()> {
//add_cmd::run_add_cmd(&files, &message)?;

//fs::remove_file(PathBuf::from("src/test_directory/test1.txt"))?;
// fs::remove_file(PathBuf::from("src/test_directory/test2.txt"))?;
// fs::remove_file(PathBuf::from("src/test_directory/test2.txt"))?;

// dvs get src/test_directory/test1.txt src/test_directory/test2.txt
//get_cmd::run_get_cmd(&files)?;

let empty_vec: Vec<String> = Vec::new();
let vec = status_cmd::run_status_cmd(&empty_vec)?;
let one_path = vec![String::from("src/test_directory/test2.txt")];
let vec = status_cmd::run_status_cmd(&one_path)?;
println!("{:?}", vec);
Ok(())
}
Expand Down

0 comments on commit 88dc84a

Please sign in to comment.