This repository has been archived by the owner on Apr 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for the GitLab SourceLinkServerType (#271)
- Loading branch information
Showing
11 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace SourceLink.Create.GitLab | ||
{ | ||
public class CreateTask : GitCreateTask | ||
{ | ||
public override string ConvertUrl(string origin) | ||
{ | ||
return UrlConverter.Convert(origin); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace SourceLink.Create.GitLab | ||
{ | ||
public static class UrlConverter | ||
{ | ||
public static string Convert(string origin) | ||
{ | ||
if (origin.StartsWith("git@")) | ||
{ | ||
origin = origin.Replace(':', '/'); | ||
origin = origin.Replace("git@", "https://"); | ||
} | ||
|
||
origin = origin.Replace(".git", string.Empty); | ||
origin = origin.TrimEnd('/'); | ||
var uri = new System.Uri(origin); | ||
|
||
return $"https://{uri.Authority}{uri.LocalPath}/raw/{{commit}}/*"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="../build/common.props" /> | ||
<PropertyGroup> | ||
<TargetFrameworks>netstandard1.4;net461</TargetFrameworks> | ||
<!-- https://github.com/NuGet/Home/wiki/Adding-nuget-pack-as-a-msbuild-target --> | ||
<IncludeBuildOutput>false</IncludeBuildOutput> | ||
<!--<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>--> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="15.1.548" PrivateAssets="all" /> | ||
</ItemGroup> | ||
|
||
<!-- https://docs.microsoft.com/en-us/dotnet/articles/core/preview3/tools/extensibility --> | ||
<ItemGroup Label="dotnet pack instructions"> | ||
<Content Include="SourceLink.Create.GitLab.targets"> | ||
<Pack>true</Pack> | ||
<PackagePath>build</PackagePath> | ||
</Content> | ||
|
||
<Content Include="$(OutputPath)netstandard1.4/SourceLink.Create.GitLab.dll"> | ||
<Pack>true</Pack> | ||
<PackagePath>build/netstandard1.4</PackagePath> | ||
</Content> | ||
<Content Include="$(OutputPath)netstandard1.4/SourceLink.Create.GitLab.deps.json"> | ||
<Pack>true</Pack> | ||
<PackagePath>build/netstandard1.4</PackagePath> | ||
</Content> | ||
|
||
<Content Include="$(OutputPath)net461/SourceLink.Create.GitLab.dll"> | ||
<Pack>true</Pack> | ||
<PackagePath>build/net461</PackagePath> | ||
</Content> | ||
</ItemGroup> | ||
<Import Project="..\SourceLink.Create.Shared\SourceLink.Create.Shared.projitems" Label="Shared" /> | ||
<Import Project="..\SourceLink.Shared\SourceLink.Shared.projitems" Label="Shared" /> | ||
|
||
<Import Project="../build/sourcelink.props" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<SourceLinkCreateGitLabDll Condition="'$(MSBuildRuntimeType)' == 'Core'">netstandard1.4\SourceLink.Create.GitLab.dll</SourceLinkCreateGitLabDll> | ||
<SourceLinkCreateGitLabDll Condition="'$(MSBuildRuntimeType)' != 'Core'">net461\SourceLink.Create.GitLab.dll</SourceLinkCreateGitLabDll> | ||
</PropertyGroup> | ||
<UsingTask TaskName="SourceLink.Create.GitLab.CreateTask" AssemblyFile="$(SourceLinkCreateGitLabDll)" /> | ||
|
||
<PropertyGroup> | ||
<SourceLinkCreate Condition="'$(SourceLinkCreate)' == ''">$(CI)</SourceLinkCreate> | ||
<SourceLinkCreate Condition="'$(SourceLinkCreate)' == '' and '$(BUILD_NUMBER)' != ''">true</SourceLinkCreate> | ||
<SourceLinkCreate Condition="'$(SourceLinkCreate)' == '' and '$(TF_BUILD)' != ''">true</SourceLinkCreate> | ||
<CompileDependsOn Condition="'$(SourceLinkCreate)' == 'true'">SourceLinkCreate;$(CompileDependsOn)</CompileDependsOn> | ||
<SourceLinkRepo Condition="'$(SourceLinkRepo)' == ''">$(MSBuildProjectDirectory)</SourceLinkRepo> | ||
<SourceLinkFile Condition="'$(SourceLinkFile)' == ''">$(SourceLink)</SourceLinkFile> | ||
<SourceLinkFile Condition="'$(SourceLinkFile)' == ''">$(IntermediateOutputPath)sourcelink.json</SourceLinkFile> | ||
<SourceLinkNotInGit Condition="'$(SourceLinkNotInGit)' == ''">embed</SourceLinkNotInGit> | ||
<SourceLinkHashMismatch Condition="'$(SourceLinkHashMismatch)' == ''">embed</SourceLinkHashMismatch> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<SourceLinkSources Condition="'@(SourceLinkSources)' == ''" Include="@(Compile)" Exclude="@(EmbeddedFiles)" /> | ||
</ItemGroup> | ||
|
||
<Target Name="SourceLinkCreate"> | ||
<SourceLink.Create.GitLab.CreateTask | ||
GitDirectory="$(SourceLinkGitDirectory)" | ||
Url="$(SourceLinkUrl)" | ||
File="$(SourceLinkFile)" | ||
Sources="@(SourceLinkSources)" | ||
NoAutoLF="$(SourceLinkNoAutoLF)" | ||
NotInGit="$(SourceLinkNotInGit)" | ||
HashMismatch="$(SourceLinkHashMismatch)" | ||
EmbeddedFilesIn="@(EmbeddedFiles)"> | ||
<Output PropertyName="SourceLink" TaskParameter="SourceLink" /> | ||
<Output ItemName="EmbeddedFiles" TaskParameter="EmbeddedFiles" /> | ||
</SourceLink.Create.GitLab.CreateTask> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,17 @@ public void Should_return_url_in_canonical_form_for_GitHub(string provided) | |
Assert.Equal("https://raw.githubusercontent.com/ctaggart/sourcelink-test/{commit}/*", task.ConvertUrl(provided)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("[email protected]:ctaggart/sourcelink-test.git")] | ||
[InlineData("https://gitlab.com/ctaggart/sourcelink-test.git")] | ||
[InlineData("https://gitlab.com/ctaggart/sourcelink-test")] | ||
[InlineData("https://gitlab.com/ctaggart/sourcelink-test/")] | ||
public void Should_return_url_in_canonical_form_for_GitLab(string provided) | ||
{ | ||
var task = new SourceLink.Create.GitLab.CreateTask(); | ||
Assert.Equal("https://gitlab.com/ctaggart/sourcelink-test/raw/{commit}/*", task.ConvertUrl(provided)); | ||
} | ||
|
||
[Theory] | ||
[InlineData("[email protected]:ctaggart/sourcelink-test.git")] | ||
[InlineData("https://bitbucket.org/ctaggart/sourcelink-test.git")] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters