shurcooL / home

home is Dmitri Shuralyov's personal website.
https://dmitri.shuralyov.com
MIT License
76 stars 2 forks source link

activity: Pushes containing no new commits appear suboptimally. #13

Closed dmitshur closed 7 years ago

dmitshur commented 7 years ago

This is what a (force) push that contains no new commits looks like:

image

There's extra whitespace at the bottom, making it uneven. Also, displaying an empty event containing a list of zero commits like that may not make much sense. Consider displaying the actual branch pushed to, the before and after commits?

These are the relevant public GitHub events for reference:


```JSON { "id": "6540416855", "type": "PushEvent", "actor": { "id": 1924134, "login": "shurcooL", "display_login": "shurcooL", "gravatar_id": "", "url": "https://api.github.com/users/shurcooL", "avatar_url": "https://avatars.githubusercontent.com/u/1924134?" }, "repo": { "id": 90435863, "name": "shurcooL/events", "url": "https://api.github.com/repos/shurcooL/events" }, "payload": { "push_id": 1958853295, "size": 2, "distinct_size": 2, "ref": "refs/heads/master", "head": "2a50f0a9442c7e233d4a6546087a0272224c116a", "before": "72b393d7a090ee0dfad31487bed00874dc13d9fa", "commits": [ { "sha": "19caae42bd8ee707f6814a7a8a7535f0b4a8bdc4", "author": { "email": "shurcooL@gmail.com", "name": "Dmitri Shuralyov" }, "message": "githubapi: Perform style changes.\n\nThe purpose of this commit is to make the diff of next commit smaller.\nIt applies various style changes to try to make the code more readable\nand consistent.\n\nThe two if err != nil statements after rc, err := s.fetchCommit are\nmerged into a single if/else if statement, to make it more clear that\nthe second if err != nil statement deals with the same error returned\nfrom fetchCommit. Rename the *github.ErrorResponse variable to e to\navoid shadowing original error.", "distinct": true, "url": "https://api.github.com/repos/shurcooL/events/commits/19caae42bd8ee707f6814a7a8a7535f0b4a8bdc4" }, { "sha": "2a50f0a9442c7e233d4a6546087a0272224c116a", "author": { "email": "shurcooL@gmail.com", "name": "Dmitri Shuralyov" }, "message": "githubapi: Detect \"merged\" state for comments on PRs.\n\nSince the IssueCommentEvent itself doesn't contain enough information\nfor us to know whether the PR has been merged or not, we fetch\nmentioned PRs (whether they've been merged). This is similar to us\nfetching additional information about mentioned commits.\n\nThen, we use the heuristic that if the PR is merged at present time,\nand the event had \"closed\" state, then it's replaced by \"merged\" state\ninstead.\n\nThis has a small chance of false positives. Imagine a PR was closed,\nthen someone commented on it, then it was reopened and merged. So at\npresent time, the PR is merged. But when the comment was made, the PR\nwas in fact a closed PR, not a merged PR.\n\nFixing this false positive would require fetching the time at which the\nPR was closed and comparing the event time to that. This should be done\nwhen there's an accessible test case for it, because it's hard\notherwise. Also, other parts of the code might have the same flaw, and\nshould also be vetted at that time.\n\nWhen we're using GraphQL API for fetching events, it'll likely be\nviable and trivial to directly query whether the PR was merged at the\ntime of event.\n\nResolves the following TODO comment:\n\n\t// TODO: Detect \"merged\" state somehow? It's likely going to require making an API call.", "distinct": true, "url": "https://api.github.com/repos/shurcooL/events/commits/2a50f0a9442c7e233d4a6546087a0272224c116a" } ] }, "public": true, "created_at": "2017-09-01T15:21:20Z" }, { "id": "6540330622", "type": "PushEvent", "actor": { "id": 1924134, "login": "shurcooL", "display_login": "shurcooL", "gravatar_id": "", "url": "https://api.github.com/users/shurcooL", "avatar_url": "https://avatars.githubusercontent.com/u/1924134?" }, "repo": { "id": 90435863, "name": "shurcooL/events", "url": "https://api.github.com/repos/shurcooL/events" }, "payload": { "push_id": 1958808559, "size": 0, "distinct_size": 0, "ref": "refs/heads/master", "head": "72b393d7a090ee0dfad31487bed00874dc13d9fa", "before": "2b2dabd52a5a682cbe7f4f0e35aed5d8225c5990", "commits": [ ] }, "public": true, "created_at": "2017-09-01T15:02:13Z" }, ```
dmitshur commented 7 years ago

Commit 0ea490a39817ce85bfe741b2cd8bea4cfade0326 got rid of the unhelpful whitespace:

image

dmitshur commented 7 years ago

As of commit d5a20efc09380fb01933a0712e1f582a64b1bb6c, this is what it looks like:

image