示例#1
0
        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);
        }
示例#2
0
        /// <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);
            }
        }
示例#3
0
        /// <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);
            }
        }
示例#4
0
 /// <summary>
 /// Create a branch at the current HEAD
 /// </summary>
 ///
 public void CreateBranch(GitRefNameComponent name)
 {
     CreateBranch(name, new GitRev("HEAD"));
 }