コード例 #1
0
ファイル: Program.cs プロジェクト: TyOverby/roslyn
        static int Main(string[] args)
        {
            var exeName = Assembly.GetExecutingAssembly().GetName().Name;
            var showHelp = false;
            var options = new Options();
            var parameters = new OptionSet()
            {
                $"Usage: {exeName} [options]",
                "Create a pull request from the specified user and branch to another specified user and branch.",
                "",
                "Options:",
                { "repopath=", "The local path to the repository.", value => options.RepositoryPath = value },
                { "sourcetype=", "The source repository type.  Valid values are 'GitHub' and 'VisualStudioOnline'.", value => options.SourceRepoType = (RepositoryType)Enum.Parse(typeof(RepositoryType), value) },
                { "sourcereponame=", "The name of the source repository.", value => options.SourceRepoName = value },
                { "sourceproject=", "The name of the source project.  Only needed for VisualStudioOnline repos.", value => options.SourceProject = value },
                { "sourceuserid=", "The source user ID.  Only needed for VisualStudioOnline repos.", value => options.SourceUserId = value },
                { "sourceuser="******"The source user name.", value => options.SourceUserName = value },
                { "sourcepassword="******"The source password.", value => options.SourcePassword = value },
                { "sourceremote=", "The source remote name.", value => options.SourceRemoteName = value },
                { "sourcebranch=", "The source branch name.", value => options.SourceBranchName = value },
                { "pushtodestination=", "If true the PR branch will be pushed to the destination repository; if false the PR branch will be pushed to the source.", value => options.PushBranchToDestination = value != null },
                { "prbranchsourceremote=", "The name of the remote the PR should initiate from.  Defaults to `sourceremote` parameter.", value => options.PullRequestBranchSourceRemote = value },
                { "destinationtype=", "The destination repository type.  Valid values are 'GitHub' and 'VisualStudioOnline'.  Defaults to `sourcetype` parameter.", value => options.DestinationRepoType = (RepositoryType)Enum.Parse(typeof(RepositoryType), value) },
                { "destinationrepoowner=", "", value => options.DestinationRepoOwner = value },
                { "destinationreponame=", "The name of the destination repository.  Defaults to `sourcereponame` parameter.", value => options.DestinationRepoName = value },
                { "destinationproject=", "The name of the destination project.  Only needed for VisualStudioOnline repos.", value => options.DestinationProject = value },
                { "destinationuserid=", "The destination user ID.  Only needed for VisualStudioOnline repos.", value => options.DestinationUserId = value },
                { "destinationuser="******"The destination user name.  Defaults to `sourceuser` parameter.", value => options.DestinationUserName = value },
                { "destinationpassword="******"The destination password.  Defaults to `sourcepassword` parameter.", value => options.DestinationPassword = value },
                { "destinationremote=", "The destination remote name.  Defaults to `sourceremote` parameter.", value => options.DestinationRemoteName = value },
                { "destinationbranch=", "The destination branch name.  Defaults to `sourcebranch` parameter.", value => options.DestinationBranchName = value },
                { "f|force", "Force the creation of the PR even if an open PR already exists.", value => options.Force = value != null },
                { "debug", "Print debugging information about the merge but don't actually create the pull request.", value => options.Debug = value != null },
                { "h|?|help", "Show this message and exit.", value => showHelp = value != null }
            };

            try
            {
                parameters.Parse(args);
                if (showHelp || !options.IsValid)
                {
                    parameters.WriteOptionDescriptions(Out);
                    return options.IsValid ? 0 : 1;
                }

                var sourceRepository = RepositoryBase.Create(options.SourceRepoType, options.RepositoryPath, options.SourceRepoName, options.SourceProject, options.SourceUserId, options.SourceUserName, options.SourcePassword, options.SourceRemoteName);
                var destRepository = RepositoryBase.Create(options.DestinationRepoType, options.RepositoryPath, options.DestinationRepoName, options.DestinationProject, options.DestinationUserId, options.DestinationUserName, options.DestinationPassword, options.DestinationRemoteName);
                new Program(sourceRepository, destRepository, options).RunAsync().GetAwaiter().GetResult();
                return 0;
            }
            catch (OptionException e)
            {
                WriteLine($"{exeName}: {e.Message}");
                WriteLine($"Try `{exeName} --help` for more information.");
                return 1;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sebgod/roslyn
        static int Main(string[] args)
        {
            var exeName = Assembly.GetExecutingAssembly().GetName().Name;
            var options = new Options();

            // default to using an environment variable, but allow an explicitly provided value to override
            options.AuthToken = Environment.GetEnvironmentVariable("AUTH_CODE");
            var parameters = new OptionSet()
            {
                $"Usage: {exeName} [options]",
                "Create a pull request from the specified user and branch to another specified user and branch.",
                "",
                "Options:",
                { "a|auth=", "The GitHub authentication token.", value => options.AuthToken = value },
                { "r|repo=", "The name of the remote repository.", value => options.RepoName = value },
                { "s|source=", "The source branch of the merge operation.", value => options.SourceBranch = value },
                { "d|dest=", "The destination branch of the merge operation.", value => options.DestinationBranch = value },
                { "su|sourceuser="******"The user hosting the source branch of the merge operation.", value => options.SourceUser = value },
                { "du|destuser="******"The user hosting the destination branch of the merge operation.", value => options.DestinationUser = value },
                { "f|force", "Force the creation of the PR even if an open PR already exists.", value => options.Force = value != null },
                { "debug", "Print debugging information about the merge but don't actually create the pull request.", value => options.Debug = value != null },
                { "h|help", "Show this message and exit.", value => options.ShowHelp = value != null }
            };

            try
            {
                parameters.Parse(args);
            }
            catch (OptionException e)
            {
                Console.WriteLine($"{exeName}: {e.Message}");
                Console.WriteLine($"Try `{exeName} --help` for more information.");
                return 1;
            }

            if (options.ShowHelp || !options.AreValid)
            {
                parameters.WriteOptionDescriptions(Console.Out);
                return options.AreValid ? 0 : 1;
            }
            else
            {
                var github = new GitHubClient(new ProductHeaderValue(options.SourceUser));
                github.Credentials = new Credentials(options.AuthToken);
                new Program(options).MakePullRequest().GetAwaiter().GetResult();
                return 0;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: TyOverby/roslyn
 private Program(RepositoryBase sourceRepository, RepositoryBase destinationRepository, Options options)
 {
     _sourceRepo = sourceRepository;
     _destRepo = destinationRepository;
     _options = options;
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: sebgod/roslyn
 private Program(Options options)
 {
     _options = options;
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: mtfgqd/roslyn
 private Program(Options options)
 {
     _options = options;
 }