forked from gitextensions/gitextensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinkFactory.cs
37 lines (33 loc) · 1.35 KB
/
LinkFactory.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Net;
namespace GitCommands
{
public class LinkFactory
{
public static string CreateLink(string caption, string uri)
{
return "<a href="+uri.Quote()+">" + WebUtility.HtmlEncode(caption) + "</a>";
}
public static string CreateTagLink(string tag)
{
if (tag != "…")
return "<a href='gitext://gototag/" + tag + "'>" + WebUtility.HtmlEncode(tag) + "</a>";
return WebUtility.HtmlEncode(tag);
}
public static string CreateBranchLink(string noPrefixBranch)
{
if (noPrefixBranch != "…")
return "<a href='gitext://gotobranch/" + noPrefixBranch + "'>" + WebUtility.HtmlEncode(noPrefixBranch) + "</a>";
return WebUtility.HtmlEncode(noPrefixBranch);
}
public static string CreateCommitLink(string guid)
{
if (GitRevision.UnstagedGuid == guid)
return "<a href='gitext://gotocommit/" + guid + "'>" + Strings.GetCurrentUnstagedChanges() + "</a>";
else if (GitRevision.IndexGuid == guid)
return "<a href='gitext://gotocommit/" + guid + "'>" + Strings.GetCurrentIndex() + "</a>";
else
return "<a href='gitext://gotocommit/" + guid + "'>" + guid.Substring(0, 10) + "</a>";
}
}
}