github: fetch dates from commits (#919)
Summary: This has two benefits: - The dates on commits are data that we will probably want when we add timestamps to authorship edges to accommodate time-weighted cred. - Once the mirror module is integrated with the GitHub plugin, we’ll want to fetch dates on commits, because this is the only real-world test case for a nested field that contains a primitive field (as opposed to a node reference), so it’ll be nice to be continually exercising that somewhat-edge case. Date strings are in commit-local time and do not depend on the time zone of the requester (in contrast to [cursors]). For example, on SourceCred: ```shell $ time node ./bin/fetchAndPrintGithubRepo.js \ > sourcecred sourcecred "${GITHUB_TOKEN}" | > jq -rc ' > .repository.defaultBranchRef.target.history.nodes[] > .author?.date[-6:] > ' | sort | uniq -c 1 +03:00 6 -04:00 717 -07:00 58 -08:00 ``` [cursors]: <https://github.com/sourcecred/sourcecred/pull/129#issuecomment-382970474> Test Plan: The snapshot contains 8 instances of `oid` and 8 instances of `date`, which is good (each of these properties appears exactly once on each commit, and nowhere else). Running `yarn test --full` passes. wchargin-branch: github-commit-dates
This commit is contained in:
parent
1155c439b9
commit
7c5923959e
|
@ -361,6 +361,7 @@ fragment commit on Commit {
|
||||||
oid
|
oid
|
||||||
message
|
message
|
||||||
author {
|
author {
|
||||||
|
date
|
||||||
user {
|
user {
|
||||||
...whoami
|
...whoami
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
"nodes": [
|
"nodes": [
|
||||||
{
|
{
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-09-12T19:48:21-07:00",
|
||||||
"user": null
|
"user": null
|
||||||
},
|
},
|
||||||
"id": "MDY6Q29tbWl0MTIzMjU1MDA2OjZiZDFiNGMwYjcxOWMyMmM2ODhhNzQ4NjNiZTA3YTY5OWI3YjliMzQ=",
|
"id": "MDY6Q29tbWl0MTIzMjU1MDA2OjZiZDFiNGMwYjcxOWMyMmM2ODhhNzQ4NjNiZTA3YTY5OWI3YjliMzQ=",
|
||||||
|
@ -16,6 +17,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-09-12T14:43:54-07:00",
|
||||||
"user": {
|
"user": {
|
||||||
"__typename": "User",
|
"__typename": "User",
|
||||||
"id": "MDQ6VXNlcjQyODE5Mzgy",
|
"id": "MDQ6VXNlcjQyODE5Mzgy",
|
||||||
|
@ -30,6 +32,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-02-28T20:25:54-08:00",
|
||||||
"user": {
|
"user": {
|
||||||
"__typename": "User",
|
"__typename": "User",
|
||||||
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
||||||
|
@ -44,6 +47,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-02-28T00:43:47-08:00",
|
||||||
"user": {
|
"user": {
|
||||||
"__typename": "User",
|
"__typename": "User",
|
||||||
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
||||||
|
@ -58,6 +62,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-02-28T00:42:09-08:00",
|
||||||
"user": {
|
"user": {
|
||||||
"__typename": "User",
|
"__typename": "User",
|
||||||
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
||||||
|
@ -72,6 +77,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-02-28T00:41:11-08:00",
|
||||||
"user": {
|
"user": {
|
||||||
"__typename": "User",
|
"__typename": "User",
|
||||||
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
||||||
|
@ -864,6 +870,7 @@
|
||||||
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg3NzQx",
|
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg3NzQx",
|
||||||
"mergeCommit": {
|
"mergeCommit": {
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-02-28T00:43:47-08:00",
|
||||||
"user": {
|
"user": {
|
||||||
"__typename": "User",
|
"__typename": "User",
|
||||||
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
||||||
|
@ -956,6 +963,7 @@
|
||||||
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg4NTIy",
|
"id": "MDExOlB1bGxSZXF1ZXN0MTcxODg4NTIy",
|
||||||
"mergeCommit": {
|
"mergeCommit": {
|
||||||
"author": {
|
"author": {
|
||||||
|
"date": "2018-02-28T20:25:54-08:00",
|
||||||
"user": {
|
"user": {
|
||||||
"__typename": "User",
|
"__typename": "User",
|
||||||
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
"id": "MDQ6VXNlcjE0MDAwMjM=",
|
||||||
|
|
|
@ -1002,7 +1002,10 @@ export type CommitJSON = {|
|
||||||
+id: string,
|
+id: string,
|
||||||
+url: string,
|
+url: string,
|
||||||
+oid: string, // the hash
|
+oid: string, // the hash
|
||||||
+author: ?{|+user: NullableAuthorJSON|},
|
+author: ?{|
|
||||||
|
+date: /* ISO 8601 */ string,
|
||||||
|
+user: NullableAuthorJSON,
|
||||||
|
|},
|
||||||
+message: string,
|
+message: string,
|
||||||
|};
|
|};
|
||||||
|
|
||||||
|
@ -1013,7 +1016,10 @@ function commitFragment(): FragmentDefinition {
|
||||||
b.field("url"),
|
b.field("url"),
|
||||||
b.field("oid"),
|
b.field("oid"),
|
||||||
b.field("message"),
|
b.field("message"),
|
||||||
b.field("author", {}, [b.field("user", {}, [b.fragmentSpread("whoami")])]),
|
b.field("author", {}, [
|
||||||
|
b.field("date"),
|
||||||
|
b.field("user", {}, [b.fragmentSpread("whoami")]),
|
||||||
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue