Skip to content

Conversation

scott-fleischman
Copy link
Contributor

GitHub API for comparing commits returns a null "sha" field when the only change to a file is to its file system permissions.

See the following repository for a complete example.
https://github.com/scott-fleischman/repo-change-file-permission

Example API call:
https://api.github.com/repos/scott-fleischman/repo-change-file-permission/compare/80fdf8f83fcd8181411919fbf47394b878c591a0...77a95bbebeb78f4fb25c6a10c3c940b6fe1caa27

Response highlight:

    "files": [
        {
            "sha": null,
            "filename": "echo-script",
            "status": "modified",
            "additions": 0,
            "deletions": 0,
            "changes": 0,
            "blob_url": "https://github.com/scott-fleischman/repo-change-file-permission/blob/77a95bbebeb78f4fb25c6a10c3c940b6fe1caa27/echo-script",
            "raw_url": "https://github.com/scott-fleischman/repo-change-file-permission/raw/77a95bbebeb78f4fb25c6a10c3c940b6fe1caa27/echo-script",
            "contents_url": "https://api.github.com/repos/scott-fleischman/repo-change-file-permission/contents/echo-script?ref=77a95bbebeb78f4fb25c6a10c3c940b6fe1caa27"
        }
    ]

@scott-fleischman
Copy link
Contributor Author

This PR also:

  • updates the samples/Repos/Commits/GitDiff.hs sample code
  • adds the specific case to the sample code
  • and adds the diff sample project to the github-samples.cabal

@@ -188,7 +188,7 @@ data File = File
, fileStatus :: !Text
, fileRawUrl :: !(Maybe URL)
, fileAdditions :: !Int
, fileSha :: !Text
, fileSha :: !(Maybe Text)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

related <*> o .: "sha" is better changed to <*> o .:? "sha", except if there is really good reason to require null existence?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good call! Fixed in ffed981

@scott-fleischman
Copy link
Contributor Author

@phadej is there anything else you would like done on this PR?

@phadej phadej self-assigned this Sep 13, 2019
…ha-permission-change

Conflicts:
samples/github-samples.cabal
@scott-fleischman
Copy link
Contributor Author

Looks like you may be back @phadej . Please let me know what I can do to get this change (or a similar one) merged so we can use this project rather than our fork. Thanks!

@phadej phadej merged commit fb2aeb6 into haskell-github:master Sep 29, 2019
@shulhi shulhi deleted the compare-file-null-sha-permission-change branch May 30, 2022 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants