コード例 #1
0
        private void TraceListenedExecute()
        {
            var auth = new GitHubAuth(GitHubAuthToken, GitHubUser, GitHubEmail);

            using (GitHubClient client = new GitHubClient(auth))
            {
                var origin = new GitHubProject(ProjectRepoName, GitHubUser);

                var upstreamBranch = new GitHubBranch(
                    ProjectRepoBranch,
                    new GitHubProject(ProjectRepoName, ProjectRepoOwner));

                string body = Body ?? string.Empty;

                if (NotifyGitHubUsers != null)
                {
                    body += PullRequestCreator.NotificationString(NotifyGitHubUsers.Select(item => item.ItemSpec));
                }

                var prCreator = new PullRequestCreator(client.Auth, GitHubAuthor);
                prCreator.CreateOrUpdateAsync(
                    CommitMessage,
                    CommitMessage + $" ({ProjectRepoBranch})",
                    body,
                    upstreamBranch,
                    origin,
                    new PullRequestOptions
                {
                    ForceCreate           = AlwaysCreateNewPullRequest,
                    MaintainersCanModify  = MaintainersCanModifyPullRequest,
                    TrackDiscardedCommits = TrackDiscardedCommits
                }).Wait();
            }
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            HandleDebugSwitch(ref args);

            bool onlyUpdate = args.Length > 0 && string.Equals("--Update", args[0], StringComparison.OrdinalIgnoreCase);

            List <BuildInfo> buildInfos = new List <BuildInfo>();

            buildInfos.Add(GetBuildInfo("CoreSetup", s_config.CoreSetupVersionFragment, fetchLatestReleaseFile: false));

            if (s_config.HasRoslynVersionFragment)
            {
                buildInfos.Add(GetBuildInfo("Roslyn", s_config.RoslynVersionFragment, fetchLatestReleaseFile: false));
            }

            IEnumerable <IDependencyUpdater> updaters = GetUpdaters();
            var dependencyBuildInfos = buildInfos.Select(buildInfo =>
                                                         new BuildDependencyInfo(
                                                             buildInfo,
                                                             upgradeStableVersions: true,
                                                             disabledPackages: Enumerable.Empty <string>()));
            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(updaters, dependencyBuildInfos);

            if (!onlyUpdate && updateResults.ChangesDetected())
            {
                GitHubAuth    gitHubAuth     = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email);
                GitHubProject origin         = new GitHubProject(s_config.GitHubProject, s_config.UserName);
                GitHubBranch  upstreamBranch = new GitHubBranch(
                    s_config.GitHubUpstreamBranch,
                    new GitHubProject(s_config.GitHubProject, s_config.GitHubUpstreamOwner));

                string suggestedMessage = updateResults.GetSuggestedCommitMessage();
                string body             = string.Empty;
                if (s_config.GitHubPullRequestNotifications.Any())
                {
                    body += PullRequestCreator.NotificationString(s_config.GitHubPullRequestNotifications);
                }

                new PullRequestCreator(gitHubAuth)
                .CreateOrUpdateAsync(
                    suggestedMessage,
                    suggestedMessage + $" ({upstreamBranch.Name})",
                    body,
                    upstreamBranch,
                    origin,
                    new PullRequestOptions())
                .Wait();
            }
        }
コード例 #3
0
        public static void Main(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            bool onlyUpdate;

            ParseArgs(args, out onlyUpdate);

            List <BuildInfo> buildInfos = new List <BuildInfo>();

            buildInfos.Add(GetBuildInfo("CoreFx", s_config.CoreFxVersionUrl, fetchLatestReleaseFile: false));
            buildInfos.Add(GetBuildInfo("CoreClr", s_config.CoreClrVersionUrl, fetchLatestReleaseFile: false));
            buildInfos.Add(GetBuildInfo("Standard", s_config.StandardVersionUrl, fetchLatestReleaseFile: false));

            IEnumerable <IDependencyUpdater> updaters = GetUpdaters();
            var dependencyBuildInfos = buildInfos.Select(buildInfo =>
                                                         new DependencyBuildInfo(
                                                             buildInfo,
                                                             upgradeStableVersions: true,
                                                             disabledPackages: Enumerable.Empty <string>()));
            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(updaters, dependencyBuildInfos);

            if (!onlyUpdate && updateResults.ChangesDetected())
            {
                GitHubAuth    gitHubAuth     = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email);
                GitHubProject origin         = new GitHubProject(s_config.GitHubProject, s_config.UserName);
                GitHubBranch  upstreamBranch = new GitHubBranch(
                    s_config.GitHubUpstreamBranch,
                    new GitHubProject(s_config.GitHubProject, s_config.GitHubUpstreamOwner));

                string suggestedMessage = updateResults.GetSuggestedCommitMessage();
                string body             = string.Empty;
                if (s_config.GitHubPullRequestNotifications.Any())
                {
                    body += PullRequestCreator.NotificationString(s_config.GitHubPullRequestNotifications);
                }

                new PullRequestCreator(gitHubAuth, origin, upstreamBranch)
                .CreateOrUpdateAsync(
                    suggestedMessage,
                    suggestedMessage + $" ({upstreamBranch.Name})",
                    body)
                .Wait();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: scslmd/corefxlab
        private static void CreatePullRequest(DependencyUpdateResults updateResults)
        {
            GitHubAuth    gitHubAuth     = new GitHubAuth(config.Password, config.UserName, config.Email);
            GitHubProject origin         = new GitHubProject(config.GitHubProject, config.UserName);
            GitHubBranch  upstreamBranch = new GitHubBranch(config.GitHubUpstreamBranch, new GitHubProject(config.GitHubProject, config.GitHubUpstreamOwner));

            string commitMessage = updateResults.GetSuggestedCommitMessage();
            string body          = string.Empty;

            if (config.GitHubPullRequestNotifications.Any())
            {
                body += PullRequestCreator.NotificationString(config.GitHubPullRequestNotifications);
            }

            new PullRequestCreator(gitHubAuth, origin, upstreamBranch)
            .CreateOrUpdateAsync(commitMessage, commitMessage + $" ({upstreamBranch.Name})", body)
            .Wait();
        }
コード例 #5
0
        public override bool Execute()
        {
            MsBuildTraceListener[] listeners = Trace.Listeners.AddMsBuildTraceListeners(Log);
            try
            {
                IDependencyUpdater[] updaters   = GetDependencyUpdaters().ToArray();
                BuildInfo[]          buildInfos = GetBuildInfos().ToArray();
                var updater = new DependencyUpdater();

                DependencyUpdateResults updateResults = updater.Update(updaters, buildInfos);

                if (updateResults.ChangesDetected())
                {
                    var gitHubAuth = new GitHubAuth(GitHubAuthToken, GitHubUser, GitHubEmail);

                    var origin = new GitHubProject(ProjectRepoName, GitHubUser);

                    var upstreamBranch = new GitHubBranch(
                        ProjectRepoBranch,
                        new GitHubProject(ProjectRepoName, ProjectRepoOwner));

                    string suggestedMessage = updateResults.GetSuggestedCommitMessage();
                    string body             = string.Empty;
                    if (NotifyGitHubUsers != null)
                    {
                        body += PullRequestCreator.NotificationString(NotifyGitHubUsers.Select(item => item.ItemSpec));
                    }

                    var prCreator = new PullRequestCreator(gitHubAuth, origin, upstreamBranch, GitHubAuthor);
                    prCreator.CreateOrUpdateAsync(
                        suggestedMessage,
                        suggestedMessage + $" ({ProjectRepoBranch})",
                        body,
                        forceCreate: AlwaysCreateNewPullRequest).Wait();
                }
            }
            finally
            {
                Trace.Listeners.RemoveMsBuildTraceListeners(listeners);
            }

            return(true);
        }
コード例 #6
0
        private void TraceListenedExecute()
        {
            // GitHub and VSTS have different dev flow conventions.
            GitHubProject origin;

            using (IGitHubClient client = CreateClient(out origin))
            {
                var upstreamBranch = new GitHubBranch(
                    ProjectRepoBranch,
                    new GitHubProject(ProjectRepoName, ProjectRepoOwner));

                string body = Body ?? string.Empty;

                if (NotifyGitHubUsers != null)
                {
                    body += PullRequestCreator.NotificationString(NotifyGitHubUsers.Select(item => item.ItemSpec));
                }

                var options = new PullRequestOptions
                {
                    ForceCreate           = AlwaysCreateNewPullRequest,
                    MaintainersCanModify  = MaintainersCanModifyPullRequest,
                    TrackDiscardedCommits = TrackDiscardedCommits
                };

                var prCreator = new PullRequestCreator(client.Auth, PullRequestAuthor);
                prCreator.CreateOrUpdateAsync(
                    CommitMessage,
                    CommitMessage + $" ({ProjectRepoBranch})",
                    body,
                    upstreamBranch,
                    origin,
                    options,
                    client).Wait();
            }
        }
コード例 #7
0
        private static async Task CreatePullRequest()
        {
            var gitHubAuth     = new GitHubAuth(_config.GithubToken, _config.GithubUsername, _config.GithubEmail);
            var origin         = new GitHubProject(_config.GithubProject, _config.GithubUsername);
            var upstreamBranch = new GitHubBranch(_config.GithubUpstreamBranch, new GitHubProject(_config.GithubProject, _config.GithubUpstreamOwner));

            var commitMessage = $"Updating external dependencies to '{ await GetOrchestratedBuildId() }'";
            var body          = string.Empty;

            if (_config.GitHubPullRequestNotifications.Any())
            {
                body += PullRequestCreator.NotificationString(_config.GitHubPullRequestNotifications);
            }

            body += $"New versions:{Environment.NewLine}";

            foreach (var updatedVersion in _config.UpdatedVersionsList)
            {
                body += $"    {updatedVersion}{Environment.NewLine}";
            }

            await new PullRequestCreator(gitHubAuth, origin, upstreamBranch)
            .CreateOrUpdateAsync(commitMessage, commitMessage + $" ({upstreamBranch.Name})", body);
        }
コード例 #8
0
        protected override void TraceListenedExecute()
        {
            // Use the commit sha of versions repo master (not just "master") for stable upgrade.
            var    gitHubAuth = new GitHubAuth(GitHubAuthToken, GitHubUser, GitHubEmail);
            var    client     = new GitHubClient(gitHubAuth);
            string masterSha  = client
                                .GetReferenceAsync(new GitHubProject("versions", "dotnet"), "heads/master")
                                .Result.Object.Sha;

            foreach (ITaskItem item in DependencyBuildInfo)
            {
                if (!string.IsNullOrEmpty(item.GetMetadata(CurrentRefMetadataName)))
                {
                    item.SetMetadata(CurrentRefMetadataName, masterSha);
                }
                string autoUpgradeBranch = item.GetMetadata(AutoUpgradeBranchMetadataName);
                if (!string.IsNullOrEmpty(autoUpgradeBranch))
                {
                    item.SetMetadata(CurrentBranchMetadataName, autoUpgradeBranch);
                }
            }

            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(
                CreateUpdaters().ToArray(),
                CreateBuildInfoDependencies().ToArray());

            // Update CurrentRef and CurrentBranch for each applicable build info used.
            if (!string.IsNullOrEmpty(CurrentRefXmlPath))
            {
                foreach (BuildInfo info in updateResults.UsedBuildInfos)
                {
                    ITaskItem infoItem = FindDependencyBuildInfo(info.Name);

                    if (!string.IsNullOrEmpty(infoItem.GetMetadata(CurrentRefMetadataName)))
                    {
                        UpdateProperty(
                            CurrentRefXmlPath,
                            $"{info.Name}{CurrentRefMetadataName}",
                            masterSha);
                    }

                    string autoUpgradeBranch = infoItem.GetMetadata(AutoUpgradeBranchMetadataName);
                    if (!string.IsNullOrEmpty(autoUpgradeBranch))
                    {
                        UpdateProperty(
                            CurrentRefXmlPath,
                            $"{info.Name}{CurrentBranchMetadataName}",
                            autoUpgradeBranch);
                    }
                }
            }

            if (updateResults.ChangesDetected())
            {
                var origin = new GitHubProject(ProjectRepoName, GitHubUser);

                var upstreamBranch = new GitHubBranch(
                    ProjectRepoBranch,
                    new GitHubProject(ProjectRepoName, ProjectRepoOwner));

                string suggestedMessage = updateResults.GetSuggestedCommitMessage();
                string body             = string.Empty;
                if (NotifyGitHubUsers != null)
                {
                    body += PullRequestCreator.NotificationString(NotifyGitHubUsers.Select(item => item.ItemSpec));
                }

                var prCreator = new PullRequestCreator(gitHubAuth, origin, upstreamBranch, GitHubAuthor);
                prCreator.CreateOrUpdateAsync(
                    suggestedMessage,
                    suggestedMessage + $" ({ProjectRepoBranch})",
                    body,
                    forceCreate: AlwaysCreateNewPullRequest).Wait();
            }
            else
            {
                Log.LogMessage("No update required: no changes detected.");
            }
        }