mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-24 11:54:59 +00:00
feature: add user/project to the view commit link menu items
Helps disambiguating links when multiple remotes contain the commit, which is typical for forges.
This commit is contained in:
parent
faec29568c
commit
d4100767a0
1 changed files with 16 additions and 4 deletions
|
@ -116,13 +116,13 @@ namespace SourceGit.ViewModels
|
|||
if (remote.TryGetVisitURL(out var url))
|
||||
{
|
||||
if (url.StartsWith("https://github.com/", StringComparison.Ordinal))
|
||||
WebLinks.Add(new Models.CommitLink() { Name = "Github", URLPrefix = $"{url}/commit/" });
|
||||
WebLinks.Add(new Models.CommitLink() { Name = CommitUrlTitle("Github", url), URLPrefix = $"{url}/commit/" });
|
||||
else if (url.StartsWith("https://gitlab.", StringComparison.Ordinal))
|
||||
WebLinks.Add(new Models.CommitLink() { Name = "GitLab", URLPrefix = $"{url}/-/commit/" });
|
||||
WebLinks.Add(new Models.CommitLink() { Name = CommitUrlTitle("GitLab", url), URLPrefix = $"{url}/-/commit/" });
|
||||
else if (url.StartsWith("https://gitee.com/", StringComparison.Ordinal))
|
||||
WebLinks.Add(new Models.CommitLink() { Name = "Gitee", URLPrefix = $"{url}/commit/" });
|
||||
WebLinks.Add(new Models.CommitLink() { Name = CommitUrlTitle("Gitee", url), URLPrefix = $"{url}/commit/" });
|
||||
else if (url.StartsWith("https://bitbucket.org/", StringComparison.Ordinal))
|
||||
WebLinks.Add(new Models.CommitLink() { Name = "Bitbucket", URLPrefix = $"{url}/commits/" });
|
||||
WebLinks.Add(new Models.CommitLink() { Name = CommitUrlTitle("Bitbucket", url), URLPrefix = $"{url}/commits/" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -639,6 +639,18 @@ namespace SourceGit.ViewModels
|
|||
menu.Items.Add(new MenuItem() { Header = "-" });
|
||||
}
|
||||
|
||||
private string CommitUrlTitle(string provider, string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
return string.Format("{0} ({1})", provider, string.Join('/', url.Split('/')[3..5]));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return provider;
|
||||
}
|
||||
}
|
||||
|
||||
[GeneratedRegex(@"^version https://git-lfs.github.com/spec/v\d+\r?\noid sha256:([0-9a-f]+)\r?\nsize (\d+)[\r\n]*$")]
|
||||
private static partial Regex REG_LFS_FORMAT();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue