|
1 | | -// Copyright (c) .NET Foundation. All rights reserved. |
| 1 | +// Copyright (c) .NET Foundation. All rights reserved. |
2 | 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. |
3 | 3 |
|
4 | 4 | using System; |
@@ -46,7 +46,7 @@ public class DisplayPackageViewModel : ListPackageItemViewModel |
46 | 46 | public bool IsRecentPackagesNoIndexEnabled { get; set; } |
47 | 47 | public bool IsMarkdigMdSyntaxHighlightEnabled { get; set; } |
48 | 48 | public bool CanDisplayReadmeWarning { get; set; } |
49 | | - public NuGetPackageGitHubInformation GitHubDependenciesInformation { get; set; } |
| 49 | + public GitHubUsageViewModel GitHubDependenciesInformation { get; set; } |
50 | 50 | public bool HasEmbeddedIcon { get; set; } |
51 | 51 | public bool HasEmbeddedReadmeFile { get; set; } |
52 | 52 | public PackageDependents PackageDependents { get; set; } |
@@ -110,6 +110,8 @@ public bool HasNewerRelease |
110 | 110 | public bool IsComputeTargetFrameworkEnabled { get; set; } |
111 | 111 | public PackageFrameworkCompatibility PackageFrameworkCompatibility { get; set; } |
112 | 112 |
|
| 113 | + public string ComparableGitHubRepository { get; private set; } |
| 114 | + |
113 | 115 | public void InitializeRepositoryMetadata(string repositoryUrl, string repositoryType) |
114 | 116 | { |
115 | 117 | RepositoryType = RepositoryKind.Unknown; |
@@ -138,6 +140,36 @@ public void InitializeRepositoryMetadata(string repositoryUrl, string repository |
138 | 140 | } |
139 | 141 | } |
140 | 142 |
|
| 143 | + public void InitializeComparableGitHubRepository() |
| 144 | + { |
| 145 | + const string githubCom = "github.com/"; |
| 146 | + string comparableUrl = string.Empty; |
| 147 | + |
| 148 | + if (RepositoryUrl != null && RepositoryUrl.Contains(githubCom)) |
| 149 | + { |
| 150 | + comparableUrl = RepositoryUrl; |
| 151 | + } |
| 152 | + else if (ProjectUrl != null && ProjectUrl.Contains(githubCom)) |
| 153 | + { |
| 154 | + comparableUrl = ProjectUrl; |
| 155 | + } |
| 156 | + |
| 157 | + comparableUrl = comparableUrl.ToLowerInvariant(); |
| 158 | + comparableUrl = comparableUrl.EndsWith("/") ? comparableUrl.Substring(0, comparableUrl.Length - 1) : comparableUrl; |
| 159 | + comparableUrl = comparableUrl.EndsWith(".git") ? comparableUrl.Substring(0, comparableUrl.Length - ".git".Length) : comparableUrl; |
| 160 | + |
| 161 | + if (comparableUrl.StartsWith("git://")) |
| 162 | + { |
| 163 | + comparableUrl = comparableUrl.Replace($"git://{githubCom}", ""); |
| 164 | + } |
| 165 | + else if (comparableUrl.StartsWith("https://")) |
| 166 | + { |
| 167 | + comparableUrl = comparableUrl.Replace($"https://{githubCom}", ""); |
| 168 | + } |
| 169 | + |
| 170 | + ComparableGitHubRepository = comparableUrl; |
| 171 | + } |
| 172 | + |
141 | 173 | public bool CanDisplayNuGetPackageExplorerLink() |
142 | 174 | { |
143 | 175 | return IsNuGetPackageExplorerLinkEnabled && !string.IsNullOrEmpty(NuGetPackageExplorerUrl) && Available; |
|
0 commit comments