svn:ignore command
This commit is contained in:
		@@ -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,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								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()?;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										12
									
								
								src/vcs.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/vcs.rs
									
									
									
									
									
								
							@@ -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> {
 | 
			
		||||
    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(())
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user