{"action":"created","issue":{"url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/226","repository_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git","labels_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/226/labels{/name}","comments_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/226/comments","events_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/226/events","html_url":"https://github.com/isomorphic-git/isomorphic-git/issues/226","id":325918035,"number":226,"title":"Question: Best way to check if a given revision exists?","user":{"login":"njlr","id":1577531,"avatar_url":"https://avatars2.githubusercontent.com/u/1577531?v=4","gravatar_id":"","url":"https://api.github.com/users/njlr","html_url":"https://github.com/njlr","followers_url":"https://api.github.com/users/njlr/followers","following_url":"https://api.github.com/users/njlr/following{/other_user}","gists_url":"https://api.github.com/users/njlr/gists{/gist_id}","starred_url":"https://api.github.com/users/njlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njlr/subscriptions","organizations_url":"https://api.github.com/users/njlr/orgs","repos_url":"https://api.github.com/users/njlr/repos","events_url":"https://api.github.com/users/njlr/events{/privacy}","received_events_url":"https://api.github.com/users/njlr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-05-24T00:05:45Z","updated_at":"2018-05-24T21:54:51Z","closed_at":"2018-05-24T21:54:51Z","author_association":"NONE","body":"First of all, thanks for all of your work on this library! \r\n\r\nI want to test if a given commit hash exists in a repo that I have cloned. I can think of two ways to do this: \r\n\r\n1. Use `git.log` and check each hash returned (slow)\r\n2. Use `git.readObject` and parse the error thrown if the revision is not found (feels a bit hacky)\r\n\r\n```\r\n    try {\r\n      await git.readObject({ \r\n        ...repo, \r\n        oid: revision \r\n      });\r\n      return true;\r\n    } catch (error) {\r\n      if (error.message.includes('Failed to read git object with oid')) {\r\n        return false;\r\n      }\r\n      throw error;\r\n    }\r\n```\r\n\r\nIs there a better way? "},"comment":{"url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/comments/391878238","html_url":"https://github.com/isomorphic-git/isomorphic-git/issues/226#issuecomment-391878238","issue_url":"https://api.github.com/repos/isomorphic-git/isomorphic-git/issues/226","id":391878238,"user":{"login":"njlr","id":1577531,"avatar_url":"https://avatars2.githubusercontent.com/u/1577531?v=4","gravatar_id":"","url":"https://api.github.com/users/njlr","html_url":"https://github.com/njlr","followers_url":"https://api.github.com/users/njlr/followers","following_url":"https://api.github.com/users/njlr/following{/other_user}","gists_url":"https://api.github.com/users/njlr/gists{/gist_id}","starred_url":"https://api.github.com/users/njlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njlr/subscriptions","organizations_url":"https://api.github.com/users/njlr/orgs","repos_url":"https://api.github.com/users/njlr/repos","events_url":"https://api.github.com/users/njlr/events{/privacy}","received_events_url":"https://api.github.com/users/njlr/received_events","type":"User","site_admin":false},"created_at":"2018-05-24T21:54:51Z","updated_at":"2018-05-24T21:54:51Z","author_association":"NONE","body":"Great! This works for me now and I will watch how things progress too 👍"}}
{"actor":{"display_login":"njlr"}}