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> /// Delete a tag /// </summary> /// public void DeleteTag(GitRefNameComponent name) { Guard.NotNull(name, nameof(name)); var r = ProcessExtensions.ExecuteCaptured(false, false, null, "git", "-C", Path, "tag", "-d", name); if (r.ExitCode != 0) { throw new GitException("Delete tag failed", r); } }
/// <summary> /// Create a branch /// </summary> /// public void CreateBranch(GitRefNameComponent name, GitRev target) { Guard.NotNull(name, nameof(name)); Guard.NotNull(target, nameof(target)); var r = ProcessExtensions.ExecuteCaptured(false, false, null, "git", "-C", Path, "branch", name, target); if (r.ExitCode != 0) { throw new GitException("Create branch failed", r); } }
/// <summary> /// Create a branch at the current HEAD /// </summary> /// public void CreateBranch(GitRefNameComponent name) { CreateBranch(name, new GitRev("HEAD")); }