From cd0fdbed3f4925e3129ab534f084ba418fd3585b Mon Sep 17 00:00:00 2001 From: aaron-jack-manning Date: Wed, 31 Aug 2022 08:45:37 +1000 Subject: [PATCH] svn:ignore command --- src/args.rs | 3 +++ src/main.rs | 11 ++++++++--- src/vcs.rs | 12 ++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/args.rs b/src/args.rs index d83cbe9..1bd3f1c 100644 --- a/src/args.rs +++ b/src/args.rs @@ -72,6 +72,9 @@ pub enum Command { #[clap(flatten)] options : ListOptions, }, + /// Adds the recommended svn:ignore property to the top level of the vault. + #[clap(name="svn:ignore")] + SvnIgnore, /// For tracking time against a task. Track { id_or_name : String, diff --git a/src/main.rs b/src/main.rs index e2b1479..5dc7486 100755 --- a/src/main.rs +++ b/src/main.rs @@ -83,14 +83,19 @@ fn program() -> Result<(), error::Error> { let vault_folder = &config.current_vault()?.1; vcs::command(args, vcs::Vcs::Git, vault_folder)?; } + else if let Command::Svn { args } = command { + let vault_folder = &config.current_vault()?.1; + vcs::command(args, vcs::Vcs::Svn, vault_folder)?; + } else if command == Command::GitIgnore { let vault_folder = &config.current_vault()?.1; vcs::create_gitignore(vault_folder)?; println!("Default {} file created", format::file(".gitignore")); } - else if let Command::Svn { args } = command { + else if command == Command::SvnIgnore { let vault_folder = &config.current_vault()?.1; - vcs::command(args, vcs::Vcs::Svn, vault_folder)?; + vcs::set_svn_ignore(vault_folder)?; + println!("Default svn:ignore property set"); } // Commands that require loading in the state. else { @@ -156,7 +161,7 @@ fn program() -> Result<(), error::Error> { tasks::list(options, vault_folder, &state)?; }, // All commands which are dealt with in if let chain at start. - Command::Vault(_) | Command::Config(_) | Command::Git { args : _ } | Command::Svn { args : _ } | Command::Switch { name : _ } | Command::GitIgnore => unreachable!(), + Command::Vault(_) | Command::Config(_) | Command::Git { args : _ } | Command::Svn { args : _ } | Command::Switch { name : _ } | Command::GitIgnore | Command::SvnIgnore => unreachable!(), } state.save()?; diff --git a/src/vcs.rs b/src/vcs.rs index 3f43e80..6f9a3b3 100755 --- a/src/vcs.rs +++ b/src/vcs.rs @@ -29,3 +29,15 @@ pub fn command(args : Vec, vcs : Vcs, vault_folder : &path::Path) -> Res pub fn create_gitignore(vault_folder : &path::Path) -> Result<(), error::Error> { Ok(fs::write(vault_folder.join(".gitignore"), "state.toml\ntemp.toml\ntemp.md")?) } + +pub fn set_svn_ignore(vault_folder : &path::Path) -> Result<(), error::Error> { + + let mut child = process::Command::new("svn") + .current_dir(vault_folder) + .args(&["propset", "svn:ignore", "state.toml\ntemp.toml\ntemp.md", "."]) + .spawn()?; + + let _ = child.wait()?; + + Ok(()) +}