fix: prevent adding nextsync config files
This commit is contained in:
parent
fdcd4633e5
commit
6b7a82bec6
@ -39,35 +39,19 @@ pub fn add(args: AddArgs) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// check if the file must be ignored
|
|
||||||
if !args.force && ignore_file(&f, rules.clone(), &mut ignored_f) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let path = repo_root().join(Path::new(&f));
|
let path = repo_root().join(Path::new(&f));
|
||||||
match path.exists() {
|
match path.exists() {
|
||||||
true => {
|
true => {
|
||||||
added_files.push(f);
|
add_entry(path, args.force, &mut added_files, rules.clone(), &mut ignored_f);
|
||||||
if path.is_dir() {
|
|
||||||
add_folder_content(path.to_path_buf(), &mut added_files);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
false => {
|
false => {
|
||||||
if Object::new(path.to_str().unwrap()).exists() {
|
if Object::new(path.to_str().unwrap()).exists() {
|
||||||
// object is deleted so not a present file but can still be added
|
// object is deleted so not present but can still be added for deletion
|
||||||
added_files.push(String::from(f));
|
added_files.push(String::from(f));
|
||||||
} else {
|
} else {
|
||||||
|
// try globbing if nothing has been found
|
||||||
for entry in try_globbing(path) {
|
for entry in try_globbing(path) {
|
||||||
if path::is_nextsync_config(entry.clone()) {
|
add_entry(entry, args.force, &mut added_files, rules.clone(), &mut ignored_f);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if !args.force && ignore_file(&path_buf_to_string(entry.clone()), rules.clone(), &mut ignored_f) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
added_files.push(path_buf_to_string(entry.strip_prefix(repo_root()).unwrap().to_path_buf()));
|
|
||||||
if entry.is_dir() {
|
|
||||||
add_folder_content(entry.to_path_buf(), &mut added_files);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,6 +62,24 @@ pub fn add(args: AddArgs) {
|
|||||||
write_added_files(added_files);
|
write_added_files(added_files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_entry(entry: PathBuf, force: bool, added_files: &mut Vec<String>, rules: Vec<String>, ignored_f: &mut Vec<String>) {
|
||||||
|
// ignore nextsync config files
|
||||||
|
if path::is_nextsync_config(entry.clone()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if the file must be ignored
|
||||||
|
if !force && ignore_file(&path_buf_to_string(entry.clone()), rules, ignored_f) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
added_files.push(path_buf_to_string(entry.strip_prefix(repo_root()).unwrap().to_path_buf()));
|
||||||
|
if entry.is_dir() {
|
||||||
|
add_folder_content(entry.to_path_buf(), added_files);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
fn print_ignored_files(ignored_files: Vec<String>) {
|
fn print_ignored_files(ignored_files: Vec<String>) {
|
||||||
if ignored_files.len() > 0 {
|
if ignored_files.len() > 0 {
|
||||||
// todo multiple nextsyncignore
|
// todo multiple nextsyncignore
|
||||||
|
Loading…
Reference in New Issue
Block a user