match vcs {
VersionControl::Git => {
- if fs::metadata(&path.join(".git")).is_err() {
+ if !path.join(".git").exists() {
GitRepo::init(path, config.cwd())?;
}
- let ignore = match fs::metadata(&path.join(".gitignore")) {
- Ok(_) => format!("\n{}", ignore),
- _ => ignore,
+ let ignore = if path.join(".gitignore").exists() {
+ format!("\n{}", ignore)
+ } else {
+ ignore
};
paths::append(&path.join(".gitignore"), ignore.as_bytes())?;
}
VersionControl::Hg => {
- if fs::metadata(&path.join(".hg")).is_err() {
+ if !path.join(".hg").exists() {
HgRepo::init(path, config.cwd())?;
}
- let hgignore = match fs::metadata(&path.join(".hgignore")) {
- Ok(_) => format!("\n{}", hgignore),
- _ => hgignore,
+ let hgignore = if path.join(".hgignore").exists() {
+ format!("\n{}", hgignore)
+ } else {
+ hgignore
};
paths::append(&path.join(".hgignore"), hgignore.as_bytes())?;
}
VersionControl::Pijul => {
- if fs::metadata(&path.join(".pijul")).is_err() {
+ if !path.join(".pijul").exists() {
PijulRepo::init(path, config.cwd())?;
}
- let ignore = match fs::metadata(&path.join(".ignore")) {
- Ok(_) => format!("\n{}", ignore),
- _ => ignore,
+ let ignore = if path.join(".ignore").exists() {
+ format!("\n{}", ignore)
+ } else {
+ ignore
};
paths::append(&path.join(".ignore"), ignore.as_bytes())?;
}
VersionControl::Fossil => {
- if fs::metadata(&path.join(".fossil")).is_err() {
+ if path.join(".fossil").exists() {
FossilRepo::init(path, config.cwd())?;
}
}
}
};
destinations.push(dst.display().to_string());
- hardlink_or_copy(&src, &dst)?;
+ hardlink_or_copy(src, dst)?;
if let Some(ref path) = export_dir {
if !path.exists() {
fs::create_dir_all(path)?;
}
- hardlink_or_copy(&src, &path.join(dst.file_name().unwrap()))?;
+ hardlink_or_copy(src, &path.join(dst.file_name().unwrap()))?;
}
}