Exemple #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);
        }
Exemple #2
0
        /// <summary>
        /// Try resolving a rev to a commit sha1
        /// </summary>
        ///
        public bool TryGetCommitId(GitRev rev, out GitSha1 sha1)
        {
            Guard.NotNull(rev, nameof(rev));

            try
            {
                sha1 = GetCommitId(rev);
                return(true);
            }
            catch (GitException)
            {
                sha1 = default;
                return(false);
            }
        }
Exemple #3
0
        public GitCommitInfo(
            GitSha1 sha1,
            IEnumerable <GitSha1> parentSha1s,
            string author,
            DateTimeOffset authorDate,
            string committer,
            DateTimeOffset commitDate,
            IReadOnlyList <string> messageLines)
        {
            Guard.NotNull(sha1, nameof(sha1));
            Guard.NotNull(parentSha1s, nameof(parentSha1s));
            Guard.NotNull(author, nameof(author));
            Guard.NotNull(committer, nameof(committer));
            Guard.NotNull(messageLines, nameof(messageLines));

            Sha1         = sha1;
            ParentSha1s  = parentSha1s.ToList();
            Author       = author;
            AuthorDate   = authorDate;
            Committer    = committer;
            CommitDate   = commitDate;
            MessageLines = messageLines;
        }