public GitRef(GitFullRefName fullName, GitSha1 target) { Guard.NotNull(fullName, nameof(fullName)); Guard.NotNull(target, nameof(target)); FullName = fullName; Name = new GitRefNameComponent(fullName.ToString().Split('/').Last()); Target = target; IsBranch = FullName.ToString().StartsWith("refs/heads/", StringComparison.Ordinal); IsTag = FullName.ToString().StartsWith("refs/tags/", StringComparison.Ordinal); }
/// <summary> /// Get a symbolic ref's target /// </summary> /// /// <returns> /// The name of the symbolic ref's target /// - OR - /// <c>null</c> if the ref is not symbolic /// - OR - /// <c>null</c> if the ref doesn't exist /// </returns> /// public GitFullRefName FindSymbolicRefTarget(GitFullRefName name) { Guard.NotNull(name, nameof(name)); var r = ProcessExtensions.ExecuteCaptured(false, false, null, "git", "-C", Path, "symbolic-ref", name); if (r.ExitCode != 0) { return(null); } return(new GitFullRefName(r.StandardOutput.Trim())); }