Unified · Split
| @@ -51,9 +51,9 @@ struct Opts { · 50 unmodified lines | |||
| 51 | /// Omit personally identifiable information, leaving only the summary. | 51 | /// Omit personally identifiable information, leaving only the summary. |
| 52 | #[clap(short = 'p', long)] | 52 | #[clap(short = 'p', long)] |
| 53 | omit_pii: bool, | 53 | omit_pii: bool, |
| 54 | /// Unify identities by name and email. | 54 | /// Omit unifying identities by name and email. |
| 55 | #[clap(short = 'i', long)] | 55 | #[clap(short = 'i', long)] |
| 56 | unify_identities: bool, | 56 | omit_unify_identities: bool, |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | fn main() -> anyhow::Result<()> { | 59 | fn main() -> anyhow::Result<()> { |
| @@ -146,13 +146,13 @@ fn main() -> anyhow::Result<()> { · 86 unmodified lines | |||
| 146 | results_by_hours.push(estimate_hours(commits)); | 146 | results_by_hours.push(estimate_hours(commits)); |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | let num_contributors = results_by_hours.len(); | 149 | let num_authors = results_by_hours.len(); |
| 150 | let mut results_by_hours = if opts.unify_identities { | 150 | let mut results_by_hours = if !opts.omit_unify_identities { |
| 151 | let start = Instant::now(); | 151 | let start = Instant::now(); |
| 152 | let res = deduplicate_identities(&results_by_hours); | 152 | let res = deduplicate_identities(&results_by_hours); |
| 153 | let elapsed = start.elapsed(); | 153 | let elapsed = start.elapsed(); |
| 154 | eprintln!( | 154 | eprintln!( |
| 155 | "Deduplicated {} contributors in {:.02}s by name and email, now {}", | 155 | "Deduplicated {} authors in {:.02}s by name and email, now {}", |
| 156 | results_by_hours.len(), | 156 | results_by_hours.len(), |
| 157 | elapsed.as_secs_f32(), | 157 | elapsed.as_secs_f32(), |
| 158 | res.len() | 158 | res.len() |
| @@ -166,7 +166,7 @@ fn main() -> anyhow::Result<()> { · 7 unmodified lines | |||
| 166 | acc | 166 | acc |
| 167 | }) | 167 | }) |
| 168 | }; | 168 | }; |
| 169 | let num_unique_contributors = results_by_hours.len(); | 169 | let num_unique_authors = results_by_hours.len(); |
| 170 | if !opts.omit_pii { | 170 | if !opts.omit_pii { |
| 171 | results_by_hours.sort_by(|a, b| a.hours.partial_cmp(&b.hours).unwrap_or(std::cmp::Ordering::Equal)); | 171 | results_by_hours.sort_by(|a, b| a.hours.partial_cmp(&b.hours).unwrap_or(std::cmp::Ordering::Equal)); |
| 172 | let stdout = io::stdout(); | 172 | let stdout = io::stdout(); |
| @@ -182,18 +182,18 @@ fn main() -> anyhow::Result<()> { · 9 unmodified lines | |||
| 182 | .expect("at least one commit at this point"); | 182 | .expect("at least one commit at this point"); |
| 183 | writeln!( | 183 | writeln!( |
| 184 | io::stdout(), | 184 | io::stdout(), |
| 185 | "total hours: {:.02}\ntotal 8h days: {:.02}\ntotal commits = {}\ntotal contributors: {}", | 185 | "total hours: {:.02}\ntotal 8h days: {:.02}\ntotal commits = {}\ntotal authors: {}", |
| 186 | total_hours, | 186 | total_hours, |
| 187 | total_hours / HOURS_PER_WORKDAY, | 187 | total_hours / HOURS_PER_WORKDAY, |
| 188 | total_commits, | 188 | total_commits, |
| 189 | num_contributors | 189 | num_authors |
| 190 | )?; | 190 | )?; |
| 191 | if opts.unify_identities { | 191 | if !opts.omit_unify_identities { |
| 192 | writeln!( | 192 | writeln!( |
| 193 | io::stdout(), | 193 | io::stdout(), |
| 194 | "total unique contributors: {} ({:.02}% duplication)", | 194 | "total unique authors: {} ({:.02}% duplication)", |
| 195 | num_unique_contributors, | 195 | num_unique_authors, |
| 196 | (1.0 - (num_unique_contributors as f32 / num_contributors as f32)) * 100.0 | 196 | (1.0 - (num_unique_authors as f32 / num_authors as f32)) * 100.0 |
| 197 | )?; | 197 | )?; |
| 198 | } | 198 | } |
| 199 | assert_eq!(total_commits, all_commits.len() as u32, "need to get all commits"); | 199 | assert_eq!(total_commits, all_commits.len() as u32, "need to get all commits"); |