Пример #1
0
        /// <summary>
        /// Retrieves the content of the file whose path is specified as an argument.
        /// </summary>
        /// <returns>The content of the file.</returns>
        /// <param name="relativePathToFile">The relative path to the file whose content will be retrieved.</param>
        /// <param name="branchVersion">The branch version from which the file is retrieved. If the argument is not provided, it is retrieved from
        /// the current branch.</param>
        public string GetFileContent(string relativePathToFile, BranchVersion branchVersion = default(BranchVersion))
        {
            string branchVersionName = branchVersion.ToString();

            if (branchVersionName == null)
            {
                branchVersionName = "master";
            }
            Commit commit = null;

            if (branchVersion.IsVersion)
            {
                LibGit2Sharp.Tag tag = this.gitRepositoryHandle.Tags.FirstOrDefault((LibGit2Sharp.Tag tagSearched) => tagSearched.FriendlyName == branchVersionName);
                if (tag != null)
                {
                    commit = this.gitRepositoryHandle.Lookup <Commit>(tag.Target.Id);
                }
            }
            else
            {
                commit = this.gitRepositoryHandle.Lookup <Commit>(branchVersionName);
            }
            if (commit != null)
            {
                Blob fileBlob = (Blob)commit[relativePathToFile].Target;
                return(fileBlob.GetContentText());
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        }                                     //https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings
        public string GetTagText(LibGit2Sharp.Tag tag)
        {
            Commit commit = tag.Target as Commit;
            var    format = Format ?? "d";

            return(commit.Author.When.ToString(format));
        }
Пример #3
0
        /// <summary>
        /// Gets the author of the commit whose reference is specified in the argument.
        /// </summary>
        /// <returns>The author's signature for the commit.</returns>
        /// <param name="commitReference">The reference of the commit.</param>
        public CommitSignature?GetCommitSignature(string commitReference)
        {
            if (!this.IsRepositoryInitialized)
            {
                throw new ModuniException("The repository is not initialized.");
            }

            Commit commit = this.gitRepositoryHandle.Lookup <Commit>(commitReference);

            if (commit != null)
            {
                return(commit.Author);
            }
            else
            {
                LibGit2Sharp.Tag tag = this.gitRepositoryHandle.Tags.FirstOrDefault((LibGit2Sharp.Tag tagSearched) => tagSearched.FriendlyName == commitReference);
                if (tag != null)
                {
                    commit = this.gitRepositoryHandle.Lookup <Commit>(tag.Target.Id);
                    if (commit != null)
                    {
                        return(commit.Author);
                    }
                }
            }
            return(null);
        }
Пример #4
0
        /// <summary>
        /// Adds a new tag to the head commit whose name is specified as an argument.
        /// </summary>
        /// <param name="newTagName">The name of the new tag.</param>
        public void AddTag(string newTagName)
        {
            if (!this.IsRepositoryInitialized)
            {
                throw new ModuniException("The repository is not initialized.");
            }

            LibGit2Sharp.Tag tag = this.gitRepositoryHandle.ApplyTag(newTagName, this.gitRepositoryHandle.Config.BuildSignature(new DateTimeOffset()), "New version: " + newTagName);
            this.gitRepositoryHandle.Network.Push(this.gitRepositoryHandle.Network.Remotes["origin"], tag.CanonicalName);
        }
Пример #5
0
 internal Tag(LibGit2Sharp.Tag tag)
 {
     innerTag = tag;
 }
Пример #6
0
        public string GetTagText(LibGit2Sharp.Tag tag)
        {
            Commit commit = tag.Target as Commit;

            return(commit.Author.ToString());
        }
Пример #7
0
        public string GetTagText(LibGit2Sharp.Tag tag)
        {
            Commit commit = tag.Target as Commit;

            return(commit.Message);
        }
Пример #8
0
 public string GetTagText(LibGit2Sharp.Tag tag) => tag.FriendlyName;