-
-
Notifications
You must be signed in to change notification settings - Fork 568
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support adding file/folder to gitignore (closes #44)
- Loading branch information
Stephan Dilly
committed
Jun 1, 2020
1 parent
8e41dd2
commit 14a93cb
Showing
8 changed files
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use super::utils::{repo, work_dir}; | ||
use crate::error::Result; | ||
use scopetime::scope_time; | ||
use std::{fs::OpenOptions, io::Write}; | ||
|
||
static GITIGNORE: &str = ".gitignore"; | ||
|
||
/// add file or path to root ignore file | ||
pub fn add_to_ignore( | ||
repo_path: &str, | ||
path_to_ignore: String, | ||
) -> Result<()> { | ||
scope_time!("add_to_ignore"); | ||
|
||
let repo = repo(repo_path)?; | ||
|
||
let ignore_file = work_dir(&repo).join(GITIGNORE); | ||
|
||
let mut file = OpenOptions::new() | ||
.append(true) | ||
.create(true) | ||
.open(ignore_file)?; | ||
|
||
writeln!(file, "{}", path_to_ignore)?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters