TRAVIS_COMMIT_RANGE shows incorrect commit range if an amended commit is pushed

The value of TRAVIS_COMMIT_RANGE does not include all of the commits for a pushed branch when there has been a forced push with an amended commit. This can be seen in this build log that shows the first SHA in TRAVIS_COMMIT_RANGE very clearly not matching the first commit in the output of git log --online. (The first SHA in the range should be a083d43). The range does agree with the value represented in the UI, so this is clearly incorrect as well.

According to the event history for gonum/gonum (https://api.github.com/repos/gonum/gonum/events), the latest push event looks like this:

  {
    "id": "11766382073",
    "type": "PushEvent",
    "actor": {
      "id": 275221,
      "login": "kortschak",
      "display_login": "kortschak",
      "gravatar_id": "",
      "url": "https://api.github.com/users/kortschak",
      "avatar_url": "https://avatars.githubusercontent.com/u/275221?"
    },
    "repo": {
      "id": 86164982,
      "name": "gonum/gonum",
      "url": "https://api.github.com/repos/gonum/gonum"
    },
    "payload": {
      "push_id": 4765843925,
      "size": 2,
      "distinct_size": 2,
      "ref": "refs/heads/travis/range-exp",
      "head": "b0ba4218fdf6f538fadd3b074340f5c1b54de2be",
      "before": "df4d52ec8ab2c74b7cda8ad1489bd923d61ab9c0",
      "commits": [
        {
          "sha": "03b433242840c084194eb2ca665f6387bc6c3b4f",
          "author": {
            "email": "dan@kortschak.io",
            "name": "Dan Kortschak"
          },
          "message": "travis: hook in golangci-lint",
          "distinct": true,
          "url": "https://api.github.com/repos/gonum/gonum/commits/03b433242840c084194eb2ca665f6387bc6c3b4f"
        },
        {
          "sha": "b0ba4218fdf6f538fadd3b074340f5c1b54de2be",
          "author": {
            "email": "dan@kortschak.io",
            "name": "Dan Kortschak"
          },
          "message": "travis: report commits on branch",
          "distinct": true,
          "url": "https://api.github.com/repos/gonum/gonum/commits/b0ba4218fdf6f538fadd3b074340f5c1b54de2be"
        }
      ]
    },
    "public": true,
    "created_at": "2020-03-14T21:59:25Z",
    "org": {
      "id": 3771091,
      "login": "gonum",
      "gravatar_id": "",
      "url": "https://api.github.com/orgs/gonum",
      "avatar_url": "https://avatars.githubusercontent.com/u/3771091?"
    }
  },

In payload.before, you see df4d52ec8ab2c74b7cda8ad1489bd923d61ab9c0.

GitHub only retains 300 events, so you may have to paginate (or be completely unable) to see this payload if there is much activity on the repo before you see this message.

I don’t think this explains the issue. This morning I’ve pushed maybe about a dozen times. The issue I see here only happens when there is an amended forced push. I can get the information via git and the shell, so it’s not a huge problem though.

That is to say, the pagination is not the problem. I does look like github are misreporting the sha though.

Imprint