2

Background

I'm researching the ability to add some services on top of git web hosts (ie github, gitlab, bitbucket etc, I'm not even sure what they're called, I borrowed that term from the github wiki).

An example of what I'm trying to do is integrating a spreadsheet with one such git web host so that whenever a user adds a new row in a spreadsheet, an issue with the contents of that row is automatically created.

Naturally, these webhosts have different apis that perform these things. I can wrap them up with a facade or something but I will still need to know the kind of the webhost.

Problem

If the git repository is hosted on a cloud version of a webhost (ie Gitlab cloud or github, then knowing the kind of webhost is easy straight from the repo itself, for example this repo:

https://github.com/facebook/buck.git 

is obviously from github. However some of these providers offer users the ability to install their gihtub hosting service on their own machines.. so for example I can have gitlab installed on my aws machine, and so the above version control will look like this:

https://mydomain.com/facebook/buck.git 

Question

How can I know what kind of git webhost is associated with a repo of it's installed on a user server rather than the cloud of the provider them self?

  • Are you able to provide a plugin or something similar to extend the webhost API? I'd expect it to require a one time installation, with maybe the very rare update, to be performed by the webhost admin, who ought to have some idea what they're running. Then you can just have your client app query the new API. – 8bittree Mar 16 '17 at 22:25
2

Well-designed web APIs usually have ways to discover what versions of which endpoints are currently supported. For example, if you curl https://api.github.com, you'll get a list of all the endpoint categories the API supports. This allows for customization and smoother upgrades of individual components.

For your use case, you can check if that has an entry for issues_url, then check if that endpoint responds in a github-like way, then you know it's a github server. If not, you can repeat the process for the other kinds of servers. Once you know what kind of server it is, you can store that for future use, and avoid guessing. If you make a couple wrong guesses, the worst you're going to get is some weird 404s in your logs.

0

You can't, at least not in general (not until auto-discoverable APIs are actually a thing, anyway). But since you're going to have to support a limited set of APIs in any case, and since the humans actually using the interface can be expected to know the host rather well for such a system, how about giving them a simple list to select the type of web host from?

  • Yeah I thought of that.. but based on my market research.. a lot of business owners don't even know what git web host their outsourcing companies use.. oh well – abbood Mar 16 '17 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.