svn:ignore command

This commit is contained in:
aaron-jack-manning 2022-08-31 08:45:37 +10:00
parent ac9f0a5532
commit cd0fdbed3f
3 changed files with 23 additions and 3 deletions

View File

@ -72,6 +72,9 @@ pub enum Command {
#[clap(flatten)] #[clap(flatten)]
options : ListOptions, 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. /// For tracking time against a task.
Track { Track {
id_or_name : String, id_or_name : String,

View File

@ -83,14 +83,19 @@ fn program() -> Result<(), error::Error> {
let vault_folder = &config.current_vault()?.1; let vault_folder = &config.current_vault()?.1;
vcs::command(args, vcs::Vcs::Git, vault_folder)?; 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 { else if command == Command::GitIgnore {
let vault_folder = &config.current_vault()?.1; let vault_folder = &config.current_vault()?.1;
vcs::create_gitignore(vault_folder)?; vcs::create_gitignore(vault_folder)?;
println!("Default {} file created", format::file(".gitignore")); 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; 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. // Commands that require loading in the state.
else { else {
@ -156,7 +161,7 @@ fn program() -> Result<(), error::Error> {
tasks::list(options, vault_folder, &state)?; tasks::list(options, vault_folder, &state)?;
}, },
// All commands which are dealt with in if let chain at start. // 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()?; state.save()?;

View File

@ -29,3 +29,15 @@ pub fn command(args : Vec<String>, vcs : Vcs, vault_folder : &path::Path) -> Res
pub fn create_gitignore(vault_folder : &path::Path) -> Result<(), error::Error> { pub fn create_gitignore(vault_folder : &path::Path) -> Result<(), error::Error> {
Ok(fs::write(vault_folder.join(".gitignore"), "state.toml\ntemp.toml\ntemp.md")?) 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(())
}