コード例 #1
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            if (options.IssueNumber <= 0)
            {
                throw new ArgumentException("Issue Number is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is not XtiVersionBranchName)
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not a version branch");
            }
            var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            var issue = await gitHubRepo.Issue(options.IssueNumber);

            gitRepo.CheckoutBranch(issue.BranchName().Value);
        }
コード例 #2
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.AppName))
            {
                throw new ArgumentException("App Name is required");
            }
            if (string.IsNullOrWhiteSpace(options.AppType))
            {
                throw new ArgumentException("App Type is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var branchName    = gitRepo.CurrentBranchName();
            var xtiBranchName = XtiBranchName.Parse(branchName);

            if (xtiBranchName is not XtiVersionBranchName versionBranchName)
            {
                throw new ArgumentException($"Branch '{branchName}' is not a version branch");
            }
            var version = await hubApi.AppRegistration.BeginPublish.Invoke(new GetVersionRequest
            {
                AppKey     = options.AppKey(),
                VersionKey = AppVersionKey.Parse(versionBranchName.Version.Key)
            });

            var output = new VersionOutput();

            output.Output(version, options.OutputPath);
        }
コード例 #3
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is not XtiIssueBranchName issueBranchName)
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not an issue branch");
            }
            var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            var issue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

            gitRepo.CommitChanges(issue.Title);
            await gitHubRepo.CompleteIssue(issueBranchName);

            var milestoneName = XtiMilestoneName.Parse(issue.Milestone.Title);
            var branchName    = milestoneName.Version.BranchName();

            gitRepo.CheckoutBranch(branchName.Value);
        }
コード例 #4
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            if (string.IsNullOrWhiteSpace(options.IssueTitle))
            {
                throw new ArgumentException("Issue Title is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var gitHubRepo        = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            XtiGitVersion xtiGitVersion;
            var           xtiBranchName = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is XtiIssueBranchName issueBranchName)
            {
                if (options.StartIssue)
                {
                    throw new ArgumentException("Unable to start issue when not a version branch");
                }
                var branchIssue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

                var xtiMilestoneName = XtiMilestoneName.Parse(branchIssue.Milestone.Title);
                xtiGitVersion = xtiMilestoneName.Version;
            }
            else if (xtiBranchName is XtiVersionBranchName versionBranchName)
            {
                xtiGitVersion = versionBranchName.Version;
            }
            else
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not an issue branch or a version branch");
            }
            var issue = await gitHubRepo.CreateIssue(xtiGitVersion, options.IssueTitle);

            if (options.StartIssue)
            {
                gitRepo.CheckoutBranch(issue.BranchName().Value);
            }
        }
コード例 #5
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.AppName))
            {
                throw new ArgumentException("App Name is required");
            }
            if (string.IsNullOrWhiteSpace(options.AppType))
            {
                throw new ArgumentException("App Type is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is not XtiVersionBranchName versionBranchName)
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not a version branch");
            }
            var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            gitRepo.CommitChanges($"Version {versionBranchName.Version.Key}");
            await gitHubRepo.CompleteVersion(versionBranchName);

            var defaultBranchName = await gitHubRepo.DefaultBranchName();

            gitRepo.CheckoutBranch(defaultBranchName);
            await hubApi.AppRegistration.EndPublish.Invoke(new GetVersionRequest
            {
                AppKey     = options.AppKey(),
                VersionKey = AppVersionKey.Parse(versionBranchName.Version.Key)
            });

            gitRepo.DeleteBranch(versionBranchName.Value);
        }
コード例 #6
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var gitHubRepo        = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            XtiMilestoneName milestoneName;
            var xtiBranchName = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is XtiIssueBranchName issueBranchName)
            {
                var issue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

                milestoneName = XtiMilestoneName.Parse(issue.Milestone.Title);
            }
            else if (xtiBranchName is XtiVersionBranchName versionBranchName)
            {
                milestoneName = versionBranchName.Version.MilestoneName();
            }
            else
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not an issue branch or a version branch");
            }
            var milestone = await gitHubRepo.Milestone(milestoneName.Value);

            var issues = await gitHubRepo.OpenIssues(milestone);

            foreach (var issue in issues)
            {
                Console.WriteLine($"{issue.Number}: {issue.Title}");
            }
        }
コード例 #7
0
        public async Task Execute(VersionToolOptions options)
        {
            AppVersionModel version;
            var             gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is XtiIssueBranchName issueBranchName && !string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

                var issue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

                var milestoneName = XtiMilestoneName.Parse(issue.Milestone.Title);
                var versionKey    = AppVersionKey.Parse(milestoneName.Version.Key);
                version = await hubApi.AppRegistration.GetVersion.Invoke(new GetVersionRequest
                {
                    AppKey     = options.AppKey(),
                    VersionKey = versionKey
                });
            }