Skip to content

Commit 8942c15

Browse files
committed
Add to changelog + rustfmt
1 parent 13b395b commit 8942c15

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Print some counts when running `zola check`
1616
- Re-render all pages/sections when `anchor-link.html` is changed
1717
- Taxonomies can now have the same name in multiple languages
18+
- `zola init` can now be create sites inside the current directory
1819

1920
## 0.8.0 (2019-06-22)
2021

components/library/src/content/section.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,12 @@ Bonjour le monde"#
395395
+++
396396
Bonjour le monde"#
397397
.to_string();
398-
let res =
399-
Section::parse(Path::new("content/subcontent/_index.fr.md"), &content, &config, &PathBuf::new());
398+
let res = Section::parse(
399+
Path::new("content/subcontent/_index.fr.md"),
400+
&content,
401+
&config,
402+
&PathBuf::new(),
403+
);
400404
assert!(res.is_ok());
401405
let section = res.unwrap();
402406
assert_eq!(section.lang, "fr".to_string());

src/cmd/init.rs

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,29 @@ pub fn is_directory_quasi_empty(path: &Path) -> Result<bool> {
3131
if path.is_dir() {
3232
let mut entries = match path.read_dir() {
3333
Ok(entries) => entries,
34-
Err(e) => { bail!("Could not read `{}` because of error: {}", path.to_string_lossy().to_string(), e); }
34+
Err(e) => {
35+
bail!(
36+
"Could not read `{}` because of error: {}",
37+
path.to_string_lossy().to_string(),
38+
e
39+
);
40+
}
3541
};
3642
// If any entry raises an error or isn't hidden (i.e. starts with `.`), we raise an error
3743
if entries.any(|x| match x {
38-
Ok(file) => !file.file_name().to_str().expect("Could not convert filename to &str").starts_with("."),
39-
Err(_) => true
44+
Ok(file) => !file
45+
.file_name()
46+
.to_str()
47+
.expect("Could not convert filename to &str")
48+
.starts_with('.'),
49+
Err(_) => true,
4050
}) {
41-
return Ok(false)
51+
return Ok(false);
4252
}
43-
return Ok(true)
44-
} else {
45-
return Ok(false)
53+
return Ok(true);
4654
}
55+
56+
Ok(false)
4757
}
4858

4959
pub fn create_new_project(name: &str) -> Result<()> {
@@ -54,7 +64,10 @@ pub fn create_new_project(name: &str) -> Result<()> {
5464
if name == "." {
5565
bail!("The current directory is not an empty folder (hidden files are ignored).");
5666
} else {
57-
bail!("`{}` is not an empty folder (hidden files are ignored).", path.to_string_lossy().to_string())
67+
bail!(
68+
"`{}` is not an empty folder (hidden files are ignored).",
69+
path.to_string_lossy().to_string()
70+
)
5871
}
5972
}
6073
} else {
@@ -96,9 +109,9 @@ pub fn create_new_project(name: &str) -> Result<()> {
96109

97110
#[cfg(test)]
98111
mod tests {
99-
use std::env::temp_dir;
100-
use std::fs::{create_dir,remove_dir,remove_dir_all};
101112
use super::*;
113+
use std::env::temp_dir;
114+
use std::fs::{create_dir, remove_dir, remove_dir_all};
102115

103116
#[test]
104117
fn init_empty_directory() {
@@ -108,7 +121,8 @@ mod tests {
108121
remove_dir_all(&dir).expect("Could not free test directory");
109122
}
110123
create_dir(&dir).expect("Could not create test directory");
111-
let allowed = is_directory_quasi_empty(&dir).expect("An error happened reading the directory's contents");
124+
let allowed = is_directory_quasi_empty(&dir)
125+
.expect("An error happened reading the directory's contents");
112126
remove_dir(&dir).unwrap();
113127
assert_eq!(true, allowed);
114128
}
@@ -124,7 +138,8 @@ mod tests {
124138
let mut content = dir.clone();
125139
content.push("content");
126140
create_dir(&content).unwrap();
127-
let allowed = is_directory_quasi_empty(&dir).expect("An error happened reading the directory's contents");
141+
let allowed = is_directory_quasi_empty(&dir)
142+
.expect("An error happened reading the directory's contents");
128143
remove_dir(&content).unwrap();
129144
remove_dir(&dir).unwrap();
130145
assert_eq!(false, allowed);
@@ -141,7 +156,8 @@ mod tests {
141156
let mut git = dir.clone();
142157
git.push(".git");
143158
create_dir(&git).unwrap();
144-
let allowed = is_directory_quasi_empty(&dir).expect("An error happened reading the directory's contents");
159+
let allowed = is_directory_quasi_empty(&dir)
160+
.expect("An error happened reading the directory's contents");
145161
remove_dir(&git).unwrap();
146162
remove_dir(&dir).unwrap();
147163
assert_eq!(true, allowed);

0 commit comments

Comments
 (0)