/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public CommitUser GetCommitUser()
        {
            var user = new CommitUser()
            {
                ExecuteID = GetGuidTag("executeid"),
                UserID    = this.UID,
                Method    = GetTag("method"),
            };

            return(user);
        }
Beispiel #2
0
        static List <RequestCommit> GetRepoCommits(string user, string repoName, string gogsBaseUrl, int numberOfCommits = 5)
        {
            List <RequestCommit> output       = new List <RequestCommit>();
            CloneOptions         cloneOptions = new CloneOptions()
            {
                Checkout = false
            };

            if (Directory.Exists("tmp"))
            {
                RecursiveDelete("tmp");
            }
            try
            {
                Repository.Clone($"{gogsBaseUrl}/{Uri.EscapeDataString(user)}/{Uri.EscapeDataString(repoName)}.git", "tmp", cloneOptions);
                using (Repository repo = new Repository("tmp"))
                {
                    foreach (var commit in repo.Commits.Take(numberOfCommits))
                    {
                        CommitUser author = new CommitUser()
                        {
                            name  = commit.Author.Name,
                            email = commit.Author.Email
                        };
                        CommitUser committer = new CommitUser()
                        {
                            name  = commit.Committer.Name,
                            email = commit.Committer.Email,
                        };
                        output.Add(new RequestCommit()
                        {
                            author    = author,
                            committer = committer,
                            id        = commit.Id.Sha,
                            message   = commit.Message,
                            url       = $"{gogsBaseUrl}/{user}/{repoName}/commit/{commit.Id.Sha}"
                        });
                    }
                }
            }
            catch
            {
                return(output);
            }
            RecursiveDelete("tmp");
            return(output);
        }