Menu

#153 Teach GitGitGadget to guess the full name and email address of new contributors

open
nobody
None
2020-01-06
2019-11-20
Anonymous
No

Originally created by: dscho

Since new contributors usually contribute their own code, we can make use of the REST API to get a single commit that has enough information to guess the full name and email address of a contributor.

Example produces this:

{
  "sha": "ccc6fb45580e1c07b143d1a55d9518c13ac3c032",
  "node_id": "MDY6Q29tbWl0MjMyNjA0NzpjY2M2ZmI0NTU4MGUxYzA3YjE0M2QxYTU1ZDk1MThjMTNhYzNjMDMy",
  "commit": {
    "author": {
      "name": "Slavica Đukić",
      "email": "slawica92@hotmail.com",
      "date": "2019-02-14T10:41:46Z"
    },
    "committer": {
      "name": "Johannes Schindelin",
      "email": "johannes.schindelin@gmx.de",
      "date": "2019-11-14T14:35:15Z"
    },
[...]
  "author": {
    "login": "slavicaDj",
    "id": 26170660,
    "node_id": "MDQ6VXNlcjI2MTcwNjYw",
    "avatar_url": "https://avatars0.githubusercontent.com/u/26170660?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/slavicaDj",
    "html_url": "https://github.com/slavicaDj",
    "followers_url": "https://api.github.com/users/slavicaDj/followers",
    "following_url": "https://api.github.com/users/slavicaDj/following{/other_user}",
    "gists_url": "https://api.github.com/users/slavicaDj/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/slavicaDj/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/slavicaDj/subscriptions",
    "organizations_url": "https://api.github.com/users/slavicaDj/orgs",
    "repos_url": "https://api.github.com/users/slavicaDj/repos",
    "events_url": "https://api.github.com/users/slavicaDj/events{/privacy}",
    "received_events_url": "https://api.github.com/users/slavicaDj/received_events",
    "type": "User",
    "site_admin": false
  },
  "committer": {
    "login": "dscho",
    "id": 127790,
    "node_id": "MDQ6VXNlcjEyNzc5MA==",
    "avatar_url": "https://avatars0.githubusercontent.com/u/127790?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/dscho",
    "html_url": "https://github.com/dscho",
    "followers_url": "https://api.github.com/users/dscho/followers",
    "following_url": "https://api.github.com/users/dscho/following{/other_user}",
    "gists_url": "https://api.github.com/users/dscho/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/dscho/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/dscho/subscriptions",
    "organizations_url": "https://api.github.com/users/dscho/orgs",
    "repos_url": "https://api.github.com/users/dscho/repos",
    "events_url": "https://api.github.com/users/dscho/events{/privacy}",
    "received_events_url": "https://api.github.com/users/dscho/received_events",
    "type": "User",
    "site_admin": false
  },
[...]
}

Even if the contributor is not the original author, they should be the committer of the tip commit (i.e. res.committer.login should be equal to pr.author) of the branch they try to contribute (and if they are not a committer, we should probably warn). And in that case, we can get the full name from res.commit.committer.name and the email address from res.commit.committer.email.

We should probably change the data type of IGitGitGadgetOptions.allowedUsers from string[] to something like {[name:string]: { fullName: string, email: string }} and cache the information in the options tracked in refs/notes/gitgitgadget, once obtained.

Discussion

  • Anonymous

    Anonymous - 2019-11-20

    Originally posted by: webstech

    fyi, it may have been a couple of months ago but allowUsers contained a null entry and a duplicate with a trailing space in the name.

     
  • Anonymous

    Anonymous - 2019-11-21

    Originally posted by: webstech

    We should probably change the data type of IGitGitGadgetOptions.allowedUsers from string[] to something like {[name:string]: { fullName: string, email: string }} and cache the information in the options tracked in refs/notes/gitgitgadget, once obtained.

    Can you clarify what problem this is solving? Are people not receiving emails?

     
  • Anonymous

    Anonymous - 2019-11-21

    Originally posted by: dscho

    We should probably change the data type of IGitGitGadgetOptions.allowedUsers from string[] to something like {[name:string]: { fullName: string, email: string }} and cache the information in the options tracked in refs/notes/gitgitgadget, once obtained.

    Can you clarify what problem this is solving? Are people not receiving emails?

    People who /submit without having a public email address on GitHub indeed do not receive the cover letter, at least.

    Having an email address to work with will also be required for https://github.com/gitgitgadget/gitgitgadget/issues/154.

     
  • Anonymous

    Anonymous - 2019-11-21

    Originally posted by: dscho

    fyi, it may have been a couple of months ago but allowUsers contained a null entry and a duplicate with a trailing space in the name.

    Right. I forgot about the null, I must have done something about the trailing space...

    clicketyclick

    Nope, still there: https://github.com/gitgitgadget/git/blob/53cdae7fc6e490f5a1aeb6d230a62be38fa5232a/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391 (look for "ghedsouza " and for null).

    I should probably edit this manually, shouldn't I ;-)

     
  • Anonymous

    Anonymous - 2020-01-06

    Originally posted by: elonderin

    not quite sure what i need to fix now so that this works and before trying out all possible fixes, i'd rather ask:
    does this fail b/c my committer name != author name or is this is some other problem ?

     

Log in to post a comment.