Skip to content

Commit

Permalink
Incomplete (config.yaml impl for new commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhexists committed Dec 17, 2023
1 parent 2ccaabf commit 70a6c99
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ pub fn create(branch_name: &String) {
let content: std::borrow::Cow<'_, str> = String::from_utf8_lossy(&content_bytes);
let mut init_content: InitLayout = serde_yaml::from_str(&content).unwrap();

init_content.branches.push(branch_name.clone());
let branch_folder: PathBuf = vault_folder.join(branch_name.clone());
init_content.branches.push(branch_name.to_string());
let branch_folder: PathBuf = vault_folder.join(branch_name);
let branch_object_folder: PathBuf = branch_folder.join("objects");
// @TODO Handle Error here with match statements
fs::create_dir(&branch_folder).unwrap();
fs::create_dir(branch_object_folder).unwrap();
create_config_yaml(&branch_folder);
println!("content of init.yaml file \n{:?}", init_content);
let yaml_string: String = serde_yaml::to_string(&init_content).unwrap();
fs::write(init_file, yaml_string).unwrap();
}
Expand Down
19 changes: 15 additions & 4 deletions src/utils/yaml_layouts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::path::Path;

use serde::{Deserialize, Serialize};

use super::get_current_branch::{self, get_current_branch};

#[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct InitLayout {
pub current_branch: String,
Expand All @@ -22,8 +25,7 @@ struct Commit {

#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct Hash {
short: String,
long: String,
hash: String,
}

impl Default for ConfigLayout {
Expand All @@ -37,7 +39,16 @@ impl Default for ConfigLayout {
}

impl ConfigLayout {
fn add_commit() {
// @TODO: Add login to update commit in struct.
fn add_commit(commit_data: &Commit) {
let current_branch: Result<String, std::io::Error> = get_current_branch();
match current_branch {
Ok(current_branch) => {
let vault_path: &Path = Path::new(".vault");
let branch_path: std::path::PathBuf = vault_path.join(current_branch);
let config_path: std::path::PathBuf = branch_path.join("config.yaml");
todo!()
}
Err(e) => panic!("Some error occurred: {e}"),
}
}
}

0 comments on commit 70a6c99

Please sign in to comment.