summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPietro Albini <pietro@pietroalbini.org>2019-08-26 10:41:28 +0200
committerPietro Albini <pietro@pietroalbini.org>2019-08-26 10:41:28 +0200
commit3c2afc1164c58a47ffe5a72b3cb308151226e2fd (patch)
treeb9e0cd2d1257fc6c3dee4ddc29306dce1fbbc640 /src
parent29019d4997d53ac083159fb0d757bbb2222556e2 (diff)
add-person: include github-id
Diffstat (limited to 'src')
-rw-r--r--src/github.rs1
-rw-r--r--src/main.rs4
2 files changed, 5 insertions, 0 deletions
diff --git a/src/github.rs b/src/github.rs
index 3810947..1d465f9 100644
--- a/src/github.rs
+++ b/src/github.rs
@@ -9,6 +9,7 @@ static TOKEN_VAR: &str = "GITHUB_TOKEN";
#[derive(serde::Deserialize)]
pub(crate) struct User {
+ pub(crate) id: usize,
pub(crate) login: String,
pub(crate) name: Option<String>,
pub(crate) email: Option<String>,
diff --git a/src/main.rs b/src/main.rs
index d8669bf..f4016db 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -73,9 +73,11 @@ fn run() -> Result<(), Error> {
}
Cli::AddPerson { ref github_name } => {
#[derive(serde::Serialize)]
+ #[serde(rename_all = "kebab-case")]
struct PersonToAdd<'a> {
name: &'a str,
github: &'a str,
+ github_id: usize,
#[serde(skip_serializing_if = "Option::is_none")]
email: Option<&'a str>,
}
@@ -83,6 +85,7 @@ fn run() -> Result<(), Error> {
let github = github::GitHubApi::new();
let user = github.user(github_name)?;
let github_name = user.login;
+ let github_id = user.id;
if data.person(&github_name).is_some() {
failure::bail!("person already in the repo: {}", github_name);
@@ -99,6 +102,7 @@ fn run() -> Result<(), Error> {
github_name.as_str()
}),
github: &github_name,
+ github_id,
email: user.email.as_ref().map(|e| e.as_str()).or_else(|| {
warn!("the person is missing the email on GitHub, leaving the field empty");
None