Skip to content

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
# Conflicts:
#	nuspec/nuget/TfsUrlParser.nuspec
  • Loading branch information
Christian Bumann committed Sep 5, 2024
2 parents f32c4f0 + db6a74d commit 278b12c
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 54 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
uses: NuGet/setup-nuget@v1

- name: Package NuGet
run: nuget pack ../nuspec/nuget/*.nuspec
run: dotnet pack -c $BUILD_CONFIG -p:PackageVersion=$BUILD_VERSION

- name: Publish NuGet
run: nuget push ./*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGETORG}}
run: nuget push ./TfsUrlParser/bin/Release/TfsUrlParser.$BUILD_VERSION.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGETORG}}
26 changes: 0 additions & 26 deletions nuspec/nuget/TfsUrlParser.nuspec

This file was deleted.

118 changes: 112 additions & 6 deletions src/TfsUrlParser.Tests/RepositoryDescriptionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
public class RepositoryDescriptionTests
{
[Theory]
[InlineData(
@"http://myserver:8080/tfs/defaultcollection/myproject/",
"No valid Git repository URL.")]
[InlineData(
@"http://myserver:8080/tfs/defaultcollection/myproject/_git",
"No valid Git repository URL.")]
[InlineData(
@"http://myserver:8080/_git/myrepository",
"No valid Git repository URL containing default collection and project name.")]
Expand All @@ -25,6 +19,7 @@ public void Should_Throw_If_No_Valid_Url(string repoUrl, string expectedMessage)
var result = Record.Exception(() => new RepositoryDescription(new Uri(repoUrl)));

// Then

result.IsUriFormatExceptionException(expectedMessage);
}

Expand Down Expand Up @@ -192,6 +187,117 @@ public void Should_Parse_Repo_Url(
repositoryDescription.ProjectName.ShouldBe(projectName);
repositoryDescription.RepositoryName.ShouldBe(repositoryName);
repositoryDescription.RepositoryUrl.ShouldBe(new Uri(repositoryUrl));
repositoryDescription.IsRepository.ShouldBe(true);
}

[Theory]
[InlineData(
@"http://myserver:8080/tfs/defaultcollection/myproject/",
@"http://myserver:8080/",
"defaultcollection",
@"http://myserver:8080/tfs/defaultcollection",
"myproject")]
[InlineData(
@"http://tfs.myserver/defaultcollection/myproject/",
@"http://tfs.myserver/",
"defaultcollection",
@"http://tfs.myserver/defaultcollection",
"myproject")]
[InlineData(
@"http://mytenant.visualstudio.com/defaultcollection/myproject/",
@"http://mytenant.visualstudio.com/",
"defaultcollection",
@"http://mytenant.visualstudio.com/defaultcollection",
"myproject")]
[InlineData(
@"http://tfs.foo.com/foo/foo",
@"http://tfs.foo.com/",
"foo",
@"http://tfs.foo.com/foo",
"foo")]
[InlineData(
@"https://myserver:8080/tfs/defaultcollection/myproject/",
@"https://myserver:8080/",
"defaultcollection",
@"https://myserver:8080/tfs/defaultcollection",
"myproject")]
[InlineData(
@"https://tfs.myserver/defaultcollection/myproject/",
@"https://tfs.myserver/",
"defaultcollection",
@"https://tfs.myserver/defaultcollection",
"myproject")]
[InlineData(
@"https://mytenant.visualstudio.com/defaultcollection/myproject/",
@"https://mytenant.visualstudio.com/",
"defaultcollection",
@"https://mytenant.visualstudio.com/defaultcollection",
"myproject")]
[InlineData(
@"https://tfs.foo.com/foo/foo/",
@"https://tfs.foo.com/",
"foo",
@"https://tfs.foo.com/foo",
"foo")]
[InlineData(
@"ssh://myserver:8080/tfs/defaultcollection/myproject/",
@"ssh://myserver:8080/",
"defaultcollection",
@"https://myserver:8080/tfs/defaultcollection",
"myproject")]
[InlineData(
@"ssh://tfs.myserver/defaultcollection/myproject/",
@"ssh://tfs.myserver/",
"defaultcollection",
@"https://tfs.myserver/defaultcollection",
"myproject")]
[InlineData(
@"ssh://mytenant.visualstudio.com/defaultcollection/myproject/",
@"ssh://mytenant.visualstudio.com/",
"defaultcollection",
@"https://mytenant.visualstudio.com/defaultcollection",
"myproject")]
[InlineData(
@"ssh://tfs.foo.com/foo/foo/",
@"ssh://tfs.foo.com/",
"foo",
@"https://tfs.foo.com/foo",
"foo")]
[InlineData(
@"ssh://foo:bar@myserver:8080/tfs/defaultcollection/myproject/",
@"ssh://myserver:8080/",
"defaultcollection",
@"https://myserver:8080/tfs/defaultcollection",
"myproject")]
[InlineData(
@"https://myorganization@dev.azure.com/myorganization/myproject/",
@"https://myorganization@dev.azure.com/",
"myorganization",
@"https://myorganization@dev.azure.com/myorganization",
"myproject")]
[InlineData(
@"https://myorganization.visualstudio.com/myproject/",
@"https://myorganization.visualstudio.com/",
"DefaultCollection",
@"https://myorganization.visualstudio.com",
"myproject")]
public void Should_Parse_NonRepo_Url(
string repoUrl,
string serverUrl,
string collectionName,
string collectionurl,
string projectName)
{
// Given / When
var repositoryDescription = new RepositoryDescription(new Uri(repoUrl));

// Then
repositoryDescription.ServerUrl.ShouldBe(new Uri(serverUrl));
repositoryDescription.CollectionName.ShouldBe(collectionName);
repositoryDescription.CollectionUrl.ShouldBe(new Uri(collectionurl));
repositoryDescription.ProjectName.ShouldBe(projectName);
repositoryDescription.IsRepository.ShouldBe(false);
}

}
}
12 changes: 6 additions & 6 deletions src/TfsUrlParser.Tests/TfsUrlParser.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>Net6.0</TargetFramework>
</PropertyGroup>
Expand All @@ -22,13 +22,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Shouldly" Version="4.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="coverlet.collector" Version="6.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
27 changes: 21 additions & 6 deletions src/TfsUrlParser/RepositoryDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ public RepositoryDescription(Uri repoUrl)

var gitSeparator = new[] { "/_git/" };
var splitPath = repoUrl.AbsolutePath.Split(gitSeparator, StringSplitOptions.None);
if (splitPath.Length < 2)
if (repoUrl.ToString().Contains("/_git/"))
{
throw new UriFormatException("No valid Git repository URL.");
this.IsRepository = true;
if (splitPath.Length < 2)
{
throw new UriFormatException("No valid Git repository URL.");
}
}
else
{
this.IsRepository = false;
}

this.ServerUrl = new Uri(repoUrl.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));
Expand All @@ -56,11 +64,13 @@ public RepositoryDescription(Uri repoUrl)
{
throw new UriFormatException("No valid Git repository URL containing default collection and project name.");
}

Check warning on line 66 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Check warning on line 66 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Check warning on line 66 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Check warning on line 66 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Check warning on line 66 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)


var splitLastPart = splitPath[1].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);

this.ProjectName = splitFirstPart.Last();
this.RepositoryName = splitLastPart.First();

if (this.IsRepository)
{
var splitLastPart = splitPath[1].Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
this.RepositoryName = splitLastPart.First();
}
}

/// <summary>
Expand Down Expand Up @@ -94,6 +104,11 @@ public RepositoryDescription(Uri repoUrl)
/// </summary>
public Uri RepositoryUrl { get; private set; }

/// <summary>
/// Get a value that indicates if this is a Git Repo or another TFS URL.
/// </summary>
public bool IsRepository { get; private set; }

Check warning on line 110 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The property's documentation summary text should begin with: 'Gets a value indicating whether' (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md)

Check warning on line 110 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The property's documentation summary text should begin with: 'Gets a value indicating whether' (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md)

Check warning on line 110 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The property's documentation summary text should begin with: 'Gets a value indicating whether' (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md)

Check warning on line 110 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The property's documentation summary text should begin with: 'Gets a value indicating whether' (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md)

Check warning on line 110 in src/TfsUrlParser/RepositoryDescription.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The property's documentation summary text should begin with: 'Gets a value indicating whether' (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1623.md)

/// <summary>
/// Converts the repository URL to a supported scheme if possible.
/// </summary>
Expand Down
32 changes: 24 additions & 8 deletions src/TfsUrlParser/TfsUrlParser.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyTitle>TfsUrlParser</AssemblyTitle>
<CodeAnalysisRuleSet>..\TfsUrlParser.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\$(Configuration)\TfsUrlParser.xml</DocumentationFile>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<PropertyGroup>
<AssemblyTitle>TfsUrlParser</AssemblyTitle>
<Company>BBT Software AG</Company>
<Title>Azure DevOps URL Parser</Title>
<Description>Provides a parser to get repository information from an Azure DevOps and Azure DevOps Server URLs.</Description>
<Product>TfsUrlParser</Product>
<Description>Azure DevOps URL Parser URL Parser</Description>
<Company>BBT Software AG</Company>
<Authors>BBT Software AG</Authors>
<Copyright>Copyright © BBT Software AG</Copyright>
<CodeAnalysisRuleSet>..\TfsUrlParser.ruleset</CodeAnalysisRuleSet>
<DocumentationFile>bin\$(Configuration)\TfsUrlParser.XML</DocumentationFile>
<OutputPath>bin\$(Configuration)\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>TfsUrlParser</PackageId>
<PackageTags>AzureDevOps Git Parser</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<PackageProjectUrl>https://github.com/bbtsoftware/TfsUrlParser/</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/bbtsoftware/TfsUrlParser.git</RepositoryUrl>
<PackageReleaseNotes>https://github.com/bbtsoftware/TfsUrlParser/releases/tag/1.5.0</PackageReleaseNotes>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb;.xml</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
Expand Down
File renamed without changes

0 comments on commit 278b12c

Please sign in to comment.