public string BuildGitLabUrl(GitLabUrlType urlType, Tuple <int, int> selectionLineRange) { // https://GitLab.com/user/repo.git string urlRoot = GetRepoUrlRoot(); // foo/bar.cs var rootDir = repository.Info.WorkingDirectory; var fileIndexPath = targetFullPath.Substring(rootDir.Length).Replace("\\", "/"); var repositoryTarget = GetGitLabTargetPath(urlType); // line selection var fragment = (selectionLineRange != null) ? (selectionLineRange.Item1 == selectionLineRange.Item2) ? string.Format("#L{0}", selectionLineRange.Item1) : string.Format("#L{0}-L{1}", selectionLineRange.Item1, selectionLineRange.Item2) : ""; var urlshowkind = "blob"; if (urlType == GitLabUrlType.Blame) { urlshowkind = "blame"; } if (urlType == GitLabUrlType.Commits) { urlshowkind = "commits"; } var fileUrl = string.Format("{0}/{4}/{1}/{2}{3}", urlRoot.Trim('/'), WebUtility.UrlEncode(repositoryTarget.Trim('/')), fileIndexPath.Trim('/'), fragment, urlshowkind); return(fileUrl); }
public string GetGitLabTargetPath(GitLabUrlType urlType) { switch (urlType) { case GitLabUrlType.CurrentBranch: return(repository.Head.FriendlyName.Replace("origin/", "")); case GitLabUrlType.CurrentRevision: return(repository.Commits.First().Id.ToString(8)); case GitLabUrlType.CurrentRevisionFull: return(repository.Commits.First().Id.Sha); case GitLabUrlType.Master: default: return("master"); } }
public string GetGitLabTargetDescription(GitLabUrlType urlType) { switch (urlType) { case GitLabUrlType.CurrentBranch: return(Strings.GitAnalysisn_Branch + repository.Head.FriendlyName.Replace("origin/", "")); case GitLabUrlType.CurrentRevision: return(Strings.GitAnalysis_Revision + repository.Commits.First().Id.ToString(8)); case GitLabUrlType.CurrentRevisionFull: return(Strings.GitAnalysis_Revision + repository.Commits.First().Id.ToString(8) + Strings.GitAnalysis_GetGitLabTargetDescription_FullID); case GitLabUrlType.Blame: return(Strings.GitAnalysis_Blame); case GitLabUrlType.Commits: return(Strings.GitAnalysis_Commits); case GitLabUrlType.Master: default: return("master"); } }