Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

(#37) Add CustomRawUrlProvider to enable arbitrary content URLs #67

Merged
merged 1 commit into from
Nov 12, 2015
Merged

Conversation

marcind
Copy link
Contributor

@marcind marcind commented Nov 9, 2015

The feature in this PR can be used to tackle a number of open scenarios:

  1. Users of standard github/bitbucket that want/need to expose file content via a different URL (i.e. my use of the proxy server to work around github's 401 obfuscation)
  2. Users of on-prem deployments of github/bitbucket (e.g. Internal bitbucket server support #66)
  3. Users of any other git-based VCS (at least as long as that system exposes an HTTP/HTTPS endpoint for accessing raw content that conforms to the following patter {rootUrl}/{revision}/{relativeFilePath} - as encoded in the inner workings of Linker.cs)

The solution is to introduce a fallback provider that uses the TargetUrl parameter as the {rootUrl} in that raw content access pattern. The usage would be as follows:

GitLink.exe c:\source\GitLink -u https://raw.githubusercontent.com/GitTools/GitLink

@GeertvanHorrik
Copy link
Contributor

Thanks! I will review as soon as I am back (thursday or friday).

[TestFixture]
public class TheInitialization
{
[TestCase]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could just create a single Test method and use test cases like this:

[TestCase("http://example.com/repo", true)]
[TestCase("gopher://example.com/repo", false)]
public void CorrectlyValidatesForUrls(string url, bool expectedValue)
{
    // Test code here
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seemed like tests for other providers used explicit test case names for the positive and negative results so I kept that pattern. Let me know if you still like it changed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a mistake made by us. Please make the change, I will change the other tests after that.

@GeertvanHorrik
Copy link
Contributor

From what I can see, this PR looks really good. I will verify with VS once I get home.

A new CustomRawUrlProvider is added that acts as the final IProvider
candidate. This provider interprets the TargetUrl parameter (`-u`) as
the url to use for the RawGitUrl property of the provider.

This enables supporting custom github/bitbucket content proxies as well
as opens up an easy way to support conforming alternative git services
without having to write a new IProvider implementation for each one.

GitLink.exe c:\source\catel -u https://raw.githubusercontent.com/catel/catel

The custom url will be used to fill in the following pattern `{customUrl}/{revision}/{raltiveFilePath}` when generating the source mapping.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raltiveFilePath => relativeFilePath

GeertvanHorrik added a commit that referenced this pull request Nov 12, 2015
(#37) Add CustomRawUrlProvider to enable arbitrary content URLs
@GeertvanHorrik GeertvanHorrik merged commit c6e3728 into GitTools:develop Nov 12, 2015
@GeertvanHorrik
Copy link
Contributor

Very nice, this is much appreciated.

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

Successfully merging this pull request may close these issues.

2 participants