Example #1
0
        private static models.Commit DetermineCommit()
        {
            // e.g.: "4.3.0 (master/[a-f0-9A-F]{7..40})"
            var regex = new Regex("^[0-9].*\\((.*)/([0-9a-f]+)\\)");
            var match = regex.Match(GetMonoVersion());

            string branch, hash;

            if (match.Success)
            {
                branch = match.Groups [1].Value;
                hash   = match.Groups [2].Value;
                Logging.GetLogging().Debug("branch: " + branch + " hash: " + hash);
            }
            else
            {
                branch = "<unknown>";
                hash   = "<unknown>";
                Logging.GetLogging().Debug("couldn't read git information: \"" + GetMonoVersion() + "\"");
            }
            Octokit.Commit gitHubCommit = null;
            try {
                var gitHubClient = GitHubInterface.GitHubClient;
                Octokit.TreeResponse treeResponse = AsyncContext.Run(() => GitHubInterface.RunWithRetry(() => gitHubClient.GitDatabase.Tree.Get("mono", "mono", hash)));
                gitHubCommit = AsyncContext.Run(() => GitHubInterface.RunWithRetry(() => gitHubClient.GitDatabase.Commit.Get("mono", "mono", treeResponse.Sha)));
            } catch (Octokit.NotFoundException e) {
                Logging.GetLogging().Debug("Commit " + hash + " not found on GitHub");
                throw e;
            }
            if (gitHubCommit == null)
            {
                Logging.GetLogging().Debug("Could not get commit " + hash + " from GitHub");
            }
            else
            {
                hash = gitHubCommit.Sha;
                // commit.CommitDate = gitHubCommit.Committer.Date.DateTime;
                Logging.GetLogging().Info("Got commit " + hash + " from GitHub");
            }

            Logging.GetLogging().InfoFormat("Benchmarker | commit \"{0}\" on branch \"{1}\"", hash, branch);
            return(new models.Commit {
                Hash = hash,
                Branch = branch,
                Product = new models.Product {
                    Name = "mono",
                    GitHubUser = "******",
                    GitHubRepo = "mono"
                }
            });
        }
Example #2
0
        private static async Task <Octokit.Commit> ResolveFullHashViaGithub(Commit commit)
        {
            if (commit == null)
            {
                return(null);
            }

            Octokit.Commit       gitHubCommit = null;
            Octokit.TreeResponse treeResponse = null;
            try {
                var gitHubClient = GitHubInterface.GitHubClient;
                treeResponse = await GitHubInterface.RunWithRetry(() => gitHubClient.GitDatabase.Tree.Get(commit.Product.GitHubUser, commit.Product.GitHubRepo, commit.Hash));

                gitHubCommit = await GitHubInterface.RunWithRetry(() => gitHubClient.GitDatabase.Commit.Get(commit.Product.GitHubUser, commit.Product.GitHubRepo, treeResponse.Sha));
            } catch (Octokit.NotFoundException) {
                Console.WriteLine("Commit " + commit + " not found on GitHub");
            }

            return(gitHubCommit);
        }