Skip to content

Commit

Permalink
Sync reviewers from rust-lang/team
Browse files Browse the repository at this point in the history
  • Loading branch information
Noratrieb committed Dec 31, 2024
1 parent 083c6f2 commit 688f5d8
Show file tree
Hide file tree
Showing 8 changed files with 687 additions and 574 deletions.
645 changes: 417 additions & 228 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ handlebars = { version = "4.1.1", features = ["dir_source"] }
walkdir = "2"
regex = "1.5.5"
mailmap = { path = "./mailmap" }
ureq = { version = "2.6.2", features = ["json"] }
unicase = "2.6.0"

[profile.release]
debug = 2
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ To run thanks, you'll need stable Rust.
There is no need to configure anything; thanks will run everything on its own, simply `cargo run
--release` and the site will be placed in `output`.

## Identities (or "help, I'm showing up multiple times")

Thanks aggregates data from commits and PR reviews.
It bases identities on the email addresses from the commits and GitHub usernames from approvals (which it maps to email addresses via rust-lang/team).
It then uses the `.mailmap` in the rust-lang/rust repository to canonicalize the identities.

If you show up multiple times, it's likely that you have contributed under multiple email addresses and haven't added them to the mailmap.
To do this, add yourself to the mailmap `.mailmap` like the example here:

```
Ferris <[email protected]>
Ferris <[email protected]> <[email protected]>
Ferris <[email protected]> <[email protected]>
```

If you change your GitHub username or someone mistyped your GitHub username in an `r=` comment, you can re-map it by adding an entry in `src/reviewers.rs`.
This is also useful if your GitHub username is not present in rust-lang/team or you encrypted the email there.

Use the `DEBUG_EMAILS=1` environment variable locally to display the email address in the output,
which is useful for debugging these missing mailmap entries.

## Refresh time

Thanks is configured to run every night to update the latest statistics.
1 change: 1 addition & 0 deletions mailmap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ categories = ["parsing"]
license = "MIT OR Apache-2.0"

[dependencies]
unicase = "2.6.0"
36 changes: 24 additions & 12 deletions mailmap/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use std::fmt;
use std::hash::Hash;
use std::pin::Pin;
use std::ptr::NonNull;

use unicase::UniCase;

#[cfg(test)]
mod test;

Expand Down Expand Up @@ -74,8 +77,17 @@ impl<'a> MapEntry<'a> {

#[derive(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)]
pub struct Author {
pub name: String,
pub email: String,
pub name: UniCase<String>,
pub email: UniCase<String>,
}

impl Author {
pub fn new(name: String, email: String) -> Self {
Self {
name: UniCase::new(name),
email: UniCase::new(email),
}
}
}

impl fmt::Debug for Author {
Expand Down Expand Up @@ -105,18 +117,18 @@ impl Mailmap {
let entry = unsafe { entry.to_entry(&self.buffer) };
if let Some(email) = entry.current_email {
if let Some(name) = entry.current_name {
if author.name == name && author.email == email {
return Author {
name: entry.canonical_name.unwrap_or(&author.name).to_owned(),
email: entry.canonical_email.expect("canonical email").to_owned(),
};
if author.name == UniCase::new(name) && author.email == UniCase::new(email) {
return Author::new(
entry.canonical_name.unwrap_or(&author.name).to_owned(),
entry.canonical_email.expect("canonical email").to_owned(),
);
}
} else {
if author.email == email {
return Author {
name: entry.canonical_name.unwrap_or(&author.name).to_owned(),
email: entry.canonical_email.expect("canonical email").to_owned(),
};
if author.email == UniCase::new(email) {
return Author::new(
entry.canonical_name.unwrap_or(&author.name).to_owned(),
entry.canonical_email.expect("canonical email").to_owned(),
);
}
}
}
Expand Down
17 changes: 6 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ impl ToAuthor for Author {
.email()
.unwrap_or_else(|| panic!("no email for {}", sig));

Author {
name: name.to_string(),
email: email.to_string(),
}
Author::new(name.to_string(), email.to_string())
}
}

Expand Down Expand Up @@ -258,10 +255,10 @@ fn commit_coauthors(commit: &Commit) -> Vec<Author> {
for line in msg.lines().rev() {
if line.starts_with("Co-authored-by") {
if let Some(caps) = RE.captures(line) {
coauthors.push(Author {
name: caps["name"].to_string(),
email: caps["email"].to_string(),
});
coauthors.push(Author::new(
caps["name"].to_string(),
caps["email"].to_string(),
));
}
}
}
Expand Down Expand Up @@ -589,14 +586,13 @@ fn main() {
eprintln!("\tcaused by: {}", cause);
cur = cause;
}
std::mem::drop(cur);
std::mem::drop(err);
std::process::exit(1);
}
}

#[derive(Debug)]
struct Submodule {
path: PathBuf,
commit: Oid,
// url
repository: String,
Expand Down Expand Up @@ -631,7 +627,6 @@ fn get_submodules(
};
assert_eq!(entry.kind().unwrap(), git2::ObjectType::Commit);
submodules.push(Submodule {
path: path.to_owned(),
commit: entry.id(),
repository: url.to_owned(),
});
Expand Down
Loading

0 comments on commit 688f5d8

Please sign in to comment.