Skip to content

Commit

Permalink
(cake-contribGH-179) Alias for file link settings for Azure DevOps
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jul 3, 2019
1 parent 728f618 commit e8852d5
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Cake.Issues.Reporting.Generic/FileLinkSettings.cs
Expand Up @@ -38,14 +38,14 @@ public class FileLinkSettings
}

/// <summary>
/// Returns settings for linking to files hosted in Visual Studio Team Service or Team Foundation Server.
/// Returns settings for linking to files hosted in Team Foundation Server.
/// </summary>
/// <param name="repositoryUrl">Full URL of the Git repository,
/// eg. <code>http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository</code>.</param>
/// <param name="branch">Name of the branch.</param>
/// <param name="rootPath">Root path of the files.
/// <c>null</c> or <see cref="string.Empty"/> if files are in the root of the repository.</param>
/// <returns>Settings for linking to files hosted in Visual Studio Team Service or Team Foundation Server.</returns>
/// <returns>Settings for linking to files hosted in Team Foundation Server.</returns>
public static FileLinkSettings TeamFoundationServer(
Uri repositoryUrl,
string branch,
Expand All @@ -54,6 +54,26 @@ public class FileLinkSettings
repositoryUrl.NotNull(nameof(repositoryUrl));
branch.NotNullOrWhiteSpace(nameof(branch));

return AzureDevOps(repositoryUrl, branch, rootPath);
}

/// <summary>
/// Returns settings for linking to files hosted in Azure DevOps or Azure DevOps Server.
/// </summary>
/// <param name="repositoryUrl">Full URL of the Git repository,
/// eg. <code>https://dev.azure.com/myorganization/_git/myrepo</code>.</param>
/// <param name="branch">Name of the branch.</param>
/// <param name="rootPath">Root path of the files.
/// <c>null</c> or <see cref="string.Empty"/> if files are in the root of the repository.</param>
/// <returns>Settings for linking to files hosted in Azure DevOps or Azure DevOps Server.</returns>
public static FileLinkSettings AzureDevOps(
Uri repositoryUrl,
string branch,
string rootPath)
{
repositoryUrl.NotNull(nameof(repositoryUrl));
branch.NotNullOrWhiteSpace(nameof(branch));

if (!string.IsNullOrWhiteSpace(rootPath))
{
rootPath = rootPath.Trim('/') + "/";
Expand Down
Expand Up @@ -107,6 +107,55 @@ public static class GenericIssueReportFormatAliases
return FileLinkSettings.TeamFoundationServer(repositoryUrl, branch, rootPath);
}

/// <summary>
/// Gets an instance of the file link settings for linking to files hosted in Azure DevOps or
/// Azure DevOps Server.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="repositoryUrl">Full URL of the Git repository,
/// eg. <code>https://dev.azure.com/myorganization/_git/myrepo</code>.</param>
/// <param name="branch">Name of the branch.</param>
/// <returns>Settings for linking files hosted on Azure DevOps or Azure DevOps Server.</returns>
[CakeMethodAlias]
[CakeAliasCategory(ReportingAliasConstants.ReportingFormatCakeAliasCategory)]
public static FileLinkSettings GenericIssueReportFileLinkSettingsForAzureDevOps(
this ICakeContext context,
Uri repositoryUrl,
string branch)
{
context.NotNull(nameof(context));
repositoryUrl.NotNull(nameof(repositoryUrl));
branch.NotNullOrWhiteSpace(nameof(branch));

return context.GenericIssueReportFileLinkSettingsForAzureDevOps(repositoryUrl, branch, null);
}

/// <summary>
/// Gets an instance of the file link settings for linking to files hosted in Azure DevOps or
/// Azure DevOps Server in a sub-folder.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="repositoryUrl">Full URL of the Git repository,
/// eg. <code>https://dev.azure.com/myorganization/_git/myrepo</code>.</param>
/// <param name="branch">Name of the branch.</param>
/// <param name="rootPath">Root path of the files.
/// <c>null</c> or <see cref="string.Empty"/> if files are in the root of the repository.</param>
/// <returns>Settings for linking files hosted on Azure DevOps or Azure DevOps Server.</returns>
[CakeMethodAlias]
[CakeAliasCategory(ReportingAliasConstants.ReportingFormatCakeAliasCategory)]
public static FileLinkSettings GenericIssueReportFileLinkSettingsForAzureDevOps(
this ICakeContext context,
Uri repositoryUrl,
string branch,
string rootPath)
{
context.NotNull(nameof(context));
repositoryUrl.NotNull(nameof(repositoryUrl));
branch.NotNullOrWhiteSpace(nameof(branch));

return FileLinkSettings.AzureDevOps(repositoryUrl, branch, rootPath);
}

/// <summary>
/// Gets an instance of a the generic report format using an embedded template.
/// </summary>
Expand Down

0 comments on commit e8852d5

Please sign in to comment.