Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub doesn't support self-hosted repositories #269

Open
adelkahomolova opened this issue Mar 10, 2020 · 10 comments
Open

GitHub doesn't support self-hosted repositories #269

adelkahomolova opened this issue Mar 10, 2020 · 10 comments

Comments

@adelkahomolova
Copy link
Contributor

GitHub can be self-hosted as well as Gitlab.

@prokopsimek prokopsimek added the Hacktoberfest https://hacktoberfest.digitalocean.com label Sep 30, 2020
@hariom1625
Copy link

Hey @adelkahomolova , I am pretty confused. What exactly needs to be done in this issue?

@adelkahomolova
Copy link
Contributor Author

Hi, @hariom1625, thank you for the question. It is necessary to find out which VCS service is used (we support GitLab, GitHub, and Bitbucket). The way, how we found it out is just by URL (checking for "GitHub" string in URL). See ScanningStrategyDetectorUtils.ts
As GitHub has also the option to have self-hosted repositories it is necessary to add this support. We've already implemented it for GitLab, so you can get the inspiration there ScanningStrategyDetector.ts
Did I answer your question? :)

@haardikdharma10
Copy link

Hey @adelkahomolova, I would love to trigger this issue and add support for GitHub. Can I go ahead?

@hariom1625
Copy link

Hi, @hariom1625, thank you for the question. It is necessary to find out which VCS service is used (we support GitLab, GitHub, and Bitbucket). The way, how we found it out is just by URL (checking for "GitHub" string in URL). See ScanningStrategyDetectorUtils.ts
As GitHub has also the option to have self-hosted repositories it is necessary to add this support. We've already implemented it for GitLab, so you can get the inspiration there ScanningStrategyDetector.ts
Did I answer your question? :)

Yes @adelkahomolova, That was helpful :-)

@adelkahomolova
Copy link
Contributor Author

@haardikdharma10 Sure! Go ahead :)

@haardikdharma10
Copy link

Thanks @adelkahomolova. I'd like some help on getting started. I went through both the files you mentioned above. The question I have is, do I need to change anything in the /src/services folder? I can see the file (GitHubService) but nothing such as githubClient similar to the one in gitlab folder (gitlabClient). Additionally, if you can help me with the files I need to edit, that'd be great :)

@prokopsimek
Copy link
Member

@haardikdharma10 Hi! Thank you for your question! There is no client for Github because we are using the Octokit library and it acts as the "Client".

There is a function to detect self-hosted Gitlab called determineGitLabRemoteServiceType: https://github.com/DXHeroes/dx-scanner/blob/master/src/detectors/ScanningStrategyDetector.ts#L193-L221 that is called in the function determineInputType: https://github.com/DXHeroes/dx-scanner/blob/master/src/detectors/ScanningStrategyDetector.ts#L90-L91

The correct solution is to create a similar function that tries to detect Github on a custom URL. E.g. to call endpoint https://api.[CUSTOM_DOMAIN] and it should return a similar response like this: https://api.github.com
According to the response format and some keys, we're able to detect that the custom URL is remote Github on any other domain than github.com.

Do not hesitate to ask us if you have any other questions. 👏

Thank you

@haardikdharma10
Copy link

@prokopsimek, Thanks a lot for such a brief and prompt response. It cleared almost everything in my head. Just to make sure before starting working on it:

  1. First thing is to add the two functions (listRepos and listGroups) in the GitHubService.ts file similar to the ones in the GitLabService.ts.
  2. Second, create a function similar to determineGitLabRemoteServiceTypeand call it in determineInputType.

If all of this sounds good to you, can I go ahead and raise a PR?

@adelkahomolova
Copy link
Contributor Author

  1. It's not about adding the same methods as we use for GitLab. You have to find out, which endpoints ensure that you can get a valid response. But in the case of getting a list of repositories and lists of groups, the answer is yes. You have to add these methods in GitHubService.ts and than use them for determining.

  2. Yes, create similar to determineGitLabRemoteServiceType but call it the same way, so determineGitHubRemoteServiceType

If it's now clear to you, go for it! 👍

@haardikdharma10

@haardikdharma10
Copy link

Thanks a lot! On it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants