Example #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);
            }
        }
        }                                     //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));
        }
Example #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);
        }
Example #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);
        }
Example #5
0
 internal Tag(LibGit2Sharp.Tag tag)
 {
     innerTag = tag;
 }
        public string GetTagText(LibGit2Sharp.Tag tag)
        {
            Commit commit = tag.Target as Commit;

            return(commit.Author.ToString());
        }
        public string GetTagText(LibGit2Sharp.Tag tag)
        {
            Commit commit = tag.Target as Commit;

            return(commit.Message);
        }
 public string GetTagText(LibGit2Sharp.Tag tag) => tag.FriendlyName;