Preserve fork relation when importing from GitHub
When we import a project from GitHub, we should preserve some metadata that allows us to re-establish fork relation.
Here is the idea:
By using the repository api: https://developer.github.com/v3/repos/#get we can check whether it's a "fork": false
or "fork": true
. When it's a fork the "parent:{}
will contain the upstream project/repository.
With that information, we can do two things:
When importing a previously forked, we look for the same project (by verifying it was imported, not a new one created at the same namespace/project
) and establish the fork relation. If none is found we store a "future fork information".
When the root project is imported, we look for any existing, previously imported project with a "future fork information" and re-establish any fork link.
For existing, previously imported projects, we can also backfill this information, if we still get oauth access to user's repositories.