Skip to content

Commit 7f37977

Browse files
spenserblacko2sh
andauthored
Convert line endings to LF (#815)
* Convert line endings to LF This should result in more reasonable diffs of future contributions where a contributor's text editor would automatically convert line endings. See #812, #813 * Create .rustfmt.toml Enforces Unix-style newlines. Co-authored-by: Ossama Hjaji <[email protected]> Co-authored-by: Ossama Hjaji <[email protected]>
1 parent 79c5a33 commit 7f37977

13 files changed

+851
-848
lines changed

.rustfmt.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# See also https://rust-lang.github.io/rustfmt for more settings.
2+
edition = "2021"
3+
newline_style = "Unix"

src/info/repo/commits.rs

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
use crate::info::{
2-
git::Commits,
3-
info_field::{InfoField, InfoType},
4-
};
5-
6-
pub struct CommitsInfo {
7-
pub number_of_commits: String,
8-
}
9-
10-
impl CommitsInfo {
11-
pub fn new(commits: &Commits) -> Self {
12-
let number_of_commits = count(commits);
13-
Self { number_of_commits }
14-
}
15-
}
16-
17-
pub fn count(commits: &Commits) -> String {
18-
format!(
19-
"{}{}",
20-
commits.num_commits,
21-
commits.is_shallow.then(|| " (shallow)").unwrap_or_default()
22-
)
23-
}
24-
impl InfoField for CommitsInfo {
25-
const TYPE: InfoType = InfoType::Commits;
26-
27-
fn value(&self) -> String {
28-
self.number_of_commits.to_string()
29-
}
30-
31-
fn title(&self) -> String {
32-
String::from("Commits")
33-
}
34-
}
35-
36-
#[cfg(test)]
37-
mod test {
38-
use super::*;
39-
40-
#[test]
41-
fn test_display_commits_info() {
42-
let commits_info = CommitsInfo {
43-
number_of_commits: "3".to_string(),
44-
};
45-
46-
assert_eq!(commits_info.value(), "3".to_string());
47-
}
48-
}
1+
use crate::info::{
2+
git::Commits,
3+
info_field::{InfoField, InfoType},
4+
};
5+
6+
pub struct CommitsInfo {
7+
pub number_of_commits: String,
8+
}
9+
10+
impl CommitsInfo {
11+
pub fn new(commits: &Commits) -> Self {
12+
let number_of_commits = count(commits);
13+
Self { number_of_commits }
14+
}
15+
}
16+
17+
pub fn count(commits: &Commits) -> String {
18+
format!(
19+
"{}{}",
20+
commits.num_commits,
21+
commits.is_shallow.then(|| " (shallow)").unwrap_or_default()
22+
)
23+
}
24+
impl InfoField for CommitsInfo {
25+
const TYPE: InfoType = InfoType::Commits;
26+
27+
fn value(&self) -> String {
28+
self.number_of_commits.to_string()
29+
}
30+
31+
fn title(&self) -> String {
32+
String::from("Commits")
33+
}
34+
}
35+
36+
#[cfg(test)]
37+
mod test {
38+
use super::*;
39+
40+
#[test]
41+
fn test_display_commits_info() {
42+
let commits_info = CommitsInfo {
43+
number_of_commits: "3".to_string(),
44+
};
45+
46+
assert_eq!(commits_info.value(), "3".to_string());
47+
}
48+
}

src/info/repo/contributors.rs

+63-63
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
use crate::info::{
2-
git::Commits,
3-
info_field::{InfoField, InfoType},
4-
};
5-
pub struct ContributorsInfo {
6-
pub number_of_contributors: usize,
7-
pub number_of_authors_to_display: usize,
8-
}
9-
10-
impl ContributorsInfo {
11-
pub fn new(commits: &Commits, number_of_authors_to_display: usize) -> Self {
12-
let contributors = number_of_contributors(commits);
13-
Self {
14-
number_of_contributors: contributors,
15-
number_of_authors_to_display,
16-
}
17-
}
18-
}
19-
20-
pub fn number_of_contributors(commits: &Commits) -> usize {
21-
commits.total_num_authors
22-
}
23-
24-
impl InfoField for ContributorsInfo {
25-
const TYPE: InfoType = InfoType::Contributors;
26-
27-
fn value(&self) -> String {
28-
if self.number_of_contributors > self.number_of_authors_to_display {
29-
self.number_of_contributors.to_string()
30-
} else {
31-
"".to_string()
32-
}
33-
}
34-
35-
fn title(&self) -> String {
36-
String::from("Contributors")
37-
}
38-
}
39-
40-
#[cfg(test)]
41-
mod test {
42-
use super::*;
43-
44-
#[test]
45-
fn test_display_contributors_info() {
46-
let contributors_info = ContributorsInfo {
47-
number_of_contributors: 12,
48-
number_of_authors_to_display: 2,
49-
};
50-
51-
assert_eq!(contributors_info.value(), "12".to_string());
52-
}
53-
54-
#[test]
55-
fn test_display_contributors_less_than_authors_to_display() {
56-
let contributors_info = ContributorsInfo {
57-
number_of_contributors: 1,
58-
number_of_authors_to_display: 3,
59-
};
60-
61-
assert!(contributors_info.value().is_empty());
62-
}
63-
}
1+
use crate::info::{
2+
git::Commits,
3+
info_field::{InfoField, InfoType},
4+
};
5+
pub struct ContributorsInfo {
6+
pub number_of_contributors: usize,
7+
pub number_of_authors_to_display: usize,
8+
}
9+
10+
impl ContributorsInfo {
11+
pub fn new(commits: &Commits, number_of_authors_to_display: usize) -> Self {
12+
let contributors = number_of_contributors(commits);
13+
Self {
14+
number_of_contributors: contributors,
15+
number_of_authors_to_display,
16+
}
17+
}
18+
}
19+
20+
pub fn number_of_contributors(commits: &Commits) -> usize {
21+
commits.total_num_authors
22+
}
23+
24+
impl InfoField for ContributorsInfo {
25+
const TYPE: InfoType = InfoType::Contributors;
26+
27+
fn value(&self) -> String {
28+
if self.number_of_contributors > self.number_of_authors_to_display {
29+
self.number_of_contributors.to_string()
30+
} else {
31+
"".to_string()
32+
}
33+
}
34+
35+
fn title(&self) -> String {
36+
String::from("Contributors")
37+
}
38+
}
39+
40+
#[cfg(test)]
41+
mod test {
42+
use super::*;
43+
44+
#[test]
45+
fn test_display_contributors_info() {
46+
let contributors_info = ContributorsInfo {
47+
number_of_contributors: 12,
48+
number_of_authors_to_display: 2,
49+
};
50+
51+
assert_eq!(contributors_info.value(), "12".to_string());
52+
}
53+
54+
#[test]
55+
fn test_display_contributors_less_than_authors_to_display() {
56+
let contributors_info = ContributorsInfo {
57+
number_of_contributors: 1,
58+
number_of_authors_to_display: 3,
59+
};
60+
61+
assert!(contributors_info.value().is_empty());
62+
}
63+
}

src/info/repo/created.rs

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
use super::gitoxide_time_to_formatted_time;
2-
use crate::info::{
3-
git::Commits,
4-
info_field::{InfoField, InfoType},
5-
};
6-
7-
pub struct CreatedInfo {
8-
pub creation_date: String,
9-
}
10-
11-
impl CreatedInfo {
12-
pub fn new(iso_time: bool, commits: &Commits) -> Self {
13-
let creation_date = get_creation_date(commits, iso_time);
14-
Self { creation_date }
15-
}
16-
}
17-
18-
pub fn get_creation_date(commits: &Commits, iso_time: bool) -> String {
19-
gitoxide_time_to_formatted_time(commits.time_of_first_commit, iso_time)
20-
}
21-
22-
impl InfoField for CreatedInfo {
23-
const TYPE: InfoType = InfoType::Created;
24-
25-
fn value(&self) -> String {
26-
self.creation_date.to_string()
27-
}
28-
29-
fn title(&self) -> String {
30-
String::from("Created")
31-
}
32-
}
33-
34-
#[cfg(test)]
35-
mod test {
36-
use super::*;
37-
38-
#[test]
39-
fn test_display_created_info() {
40-
let created_info = CreatedInfo {
41-
creation_date: "2 years ago".to_string(),
42-
};
43-
44-
assert_eq!(created_info.value(), "2 years ago".to_string());
45-
}
46-
}
1+
use super::gitoxide_time_to_formatted_time;
2+
use crate::info::{
3+
git::Commits,
4+
info_field::{InfoField, InfoType},
5+
};
6+
7+
pub struct CreatedInfo {
8+
pub creation_date: String,
9+
}
10+
11+
impl CreatedInfo {
12+
pub fn new(iso_time: bool, commits: &Commits) -> Self {
13+
let creation_date = get_creation_date(commits, iso_time);
14+
Self { creation_date }
15+
}
16+
}
17+
18+
pub fn get_creation_date(commits: &Commits, iso_time: bool) -> String {
19+
gitoxide_time_to_formatted_time(commits.time_of_first_commit, iso_time)
20+
}
21+
22+
impl InfoField for CreatedInfo {
23+
const TYPE: InfoType = InfoType::Created;
24+
25+
fn value(&self) -> String {
26+
self.creation_date.to_string()
27+
}
28+
29+
fn title(&self) -> String {
30+
String::from("Created")
31+
}
32+
}
33+
34+
#[cfg(test)]
35+
mod test {
36+
use super::*;
37+
38+
#[test]
39+
fn test_display_created_info() {
40+
let created_info = CreatedInfo {
41+
creation_date: "2 years ago".to_string(),
42+
};
43+
44+
assert_eq!(created_info.value(), "2 years ago".to_string());
45+
}
46+
}

0 commit comments

Comments
 (0)