mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
refactor: rewrite commit web links
This commit is contained in:
parent
59a7c74fd1
commit
abdf9d7e75
2 changed files with 16 additions and 21 deletions
|
@ -91,8 +91,9 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public AvaloniaList<Models.CommitLink> WebLinks
|
||||
{
|
||||
get => _repo.TryGetCommitLinks();
|
||||
}
|
||||
get;
|
||||
private set;
|
||||
} = new AvaloniaList<Models.CommitLink>();
|
||||
|
||||
public AvaloniaList<Models.IssueTrackerRule> IssueTrackerRules
|
||||
{
|
||||
|
@ -102,6 +103,19 @@ namespace SourceGit.ViewModels
|
|||
public CommitDetail(Repository repo)
|
||||
{
|
||||
_repo = repo;
|
||||
|
||||
foreach (var remote in repo.Remotes)
|
||||
{
|
||||
if (remote.TryGetVisitURL(out var url))
|
||||
{
|
||||
if (url.StartsWith("https://github.com/", StringComparison.Ordinal))
|
||||
WebLinks.Add(new Models.CommitLink() { Name = "Github", URLTemplate = $"{url}/commit/SOURCEGIT_COMMIT_HASH_CODE" });
|
||||
else if (url.StartsWith("https://gitlab.com/", StringComparison.Ordinal))
|
||||
WebLinks.Add(new Models.CommitLink() { Name = "GitLab", URLTemplate = $"{url}/-/commit/SOURCEGIT_COMMIT_HASH_CODE" });
|
||||
else if (url.StartsWith("https://gitee.com/", StringComparison.Ordinal))
|
||||
WebLinks.Add(new Models.CommitLink() { Name = "Gitee", URLTemplate = $"{url}/commit/SOURCEGIT_COMMIT_HASH_CODE" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Cleanup()
|
||||
|
|
|
@ -496,25 +496,6 @@ namespace SourceGit.ViewModels
|
|||
PopupHost.ShowAndStartPopup(new Cleanup(this));
|
||||
}
|
||||
|
||||
public AvaloniaList<Models.CommitLink> TryGetCommitLinks()
|
||||
{
|
||||
var rs = new AvaloniaList<Models.CommitLink>();
|
||||
foreach (var remote in _remotes)
|
||||
{
|
||||
if (remote.TryGetVisitURL(out var url))
|
||||
{
|
||||
if (url.StartsWith("https://github.com/", StringComparison.Ordinal))
|
||||
rs.Add(new Models.CommitLink() { Name = "Github", URLTemplate = $"{url}/commit/SOURCEGIT_COMMIT_HASH_CODE" });
|
||||
else if (url.StartsWith("https://gitlab.com/", StringComparison.Ordinal))
|
||||
rs.Add(new Models.CommitLink() { Name = "GitLab", URLTemplate = $"{url}/-/commit/SOURCEGIT_COMMIT_HASH_CODE" });
|
||||
else if (url.StartsWith("https://gitee.com/", StringComparison.Ordinal))
|
||||
rs.Add(new Models.CommitLink() { Name = "Gitee", URLTemplate = $"{url}/commit/SOURCEGIT_COMMIT_HASH_CODE" });
|
||||
}
|
||||
}
|
||||
|
||||
return rs;
|
||||
}
|
||||
|
||||
public void ClearHistoriesFilter()
|
||||
{
|
||||
_settings.Filters.Clear();
|
||||
|
|
Loading…
Reference in a new issue