Exemple #1
0
        public static async Task <string> GetUpdateText(string path)
        {
            GitHubClient client = GetClient(path);

            UpdaterSettings options = UpdaterSettings.Load(path);

            IReadOnlyList <Release> releases = await client.Repository.Release.GetAll(Settings.Default.RepositoryOwner, Settings.Default.RepositoryName);

            IReadOnlyList <GitHubCommit> commits = await client.Repository.Commit.GetAll(Settings.Default.RepositoryOwner, Settings.Default.RepositoryName);

            IEnumerable <Release> latestReleases = releases.OrderByDescending(c => c.CreatedAt).Take(15);

            StringBuilder commitMessage = new StringBuilder();

            foreach (Release release in latestReleases.Where(e => options.InstallPrereleases || !e.Prerelease))
            {
                string releaseMessage = release.Body;

                if (string.IsNullOrEmpty(releaseMessage))
                {
                    GitHubCommit commit = commits.FirstOrDefault(c => c.Commit.Sha == release.TargetCommitish);

                    releaseMessage = commit?.Commit.Message ?? "Unknown";
                }

                commitMessage.AppendLine($"{release.CreatedAt.Date.Date.ToShortDateString()}:");
                commitMessage.AppendLine(releaseMessage);
                commitMessage.AppendLine();
            }

            return(commitMessage.ToString());
        }
Exemple #2
0
        public static async Task <Release> GetLatestRelease(string path)
        {
            GitHubClient client = GetClient(path);

            UpdaterSettings options = UpdaterSettings.Load(path);

            IReadOnlyList <Release> releases = await client.Repository.Release.GetAll(Settings.Default.RepositoryOwner, Settings.Default.RepositoryName);

            Release latestRelease = releases?.OrderByDescending(r => r.CreatedAt)
                                    .FirstOrDefault(r => options.InstallPrereleases || !r.Prerelease);

            return(latestRelease);
        }
Exemple #3
0
        public static GitHubClient GetClient(string path)
        {
            UpdaterSettings options = UpdaterSettings.Load(path);

            GitHubClient client = new GitHubClient(new ProductHeaderValue(Settings.Default.RepositoryName));

            if (!string.IsNullOrEmpty(options.GithubAccessToken))
            {
                client.Credentials = new Credentials(options.GithubAccessToken);
            }

            return(client);
        }