1

Let's say there is a repository foo/bar which I forked to me/custom-bar. How do I check programmatically (API call maybe?) given foo/bar that there exists a fork that I own from this upstream? Currently, GitHub has the repos/owner/id/forks API endpoint that returns upto 100 entries if you explicitly mention it. I don't see any parameters for creating a custom query for this particular problem. Counting in the rate-limiting and stuff, I don't think it's possible to know this using this API endpoint if I had say a fork of the linux project where over 20k+ forks exist. Is there any fast and efficient way to know this?

Note: I don't want to use authentication if at all possible.

sangeeth96
  • 1,160
  • 1
  • 9
  • 19

2 Answers2

0

As a workaround... you can always try to fork your own repo (POST /repos/:owner/:repo/forks).

As explained in "Is it possible to 'fork a fork' in Github?", that won't be generally possible (for a sigle non-organization account) to do if your own repo is itself a fork.

VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755
  • I have two questions about this — 1. Wouldn't it unnecessarily create a new fork if I don't have one? 2. This is not possible w/o authentication which I don't want to do (I'll edit my query) – sangeeth96 Feb 22 '18 at 09:50
  • 1/ yes, you would need to delete it ;) 2/ yes, you need authentication: as I said, it is a *workaround*... – VonC Feb 22 '18 at 09:51
  • Hm... your workaround _works_ but I really want a non-invasive method of doing this. I wish the API allowed passing in some search options. – sangeeth96 Feb 22 '18 at 09:54
  • @SangeethSudheer I understand, and looked for such an API, but did not find one. – VonC Feb 22 '18 at 09:54
  • @SangeethSudheer That being said, https://developer.github.com/v4/ might help crafting a more precise query without the pagination issue. – VonC Feb 22 '18 at 09:55
  • :( Oh, I'll look into that and see if it's possible. Thanks for the suggestions so far. – sangeeth96 Feb 22 '18 at 09:56
0

A solution here will be:

  1. Check your repositories using GET /users/:username/repos
  2. For each repo which fork property is true, GEt repository information using GET /repos/:owner/:repo
  3. Check the parent object in json response (that contains parent folder of fork) and validate if full_name is your foo/bar repo
Juan Rada
  • 3,203
  • 1
  • 24
  • 26