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); }
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); }
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); }
public static AppKey AppKey(this VersionToolOptions options) { var appType = string.IsNullOrWhiteSpace(options.AppType) ? AppType.Values.WebApp : AppType.Values.Value(options.AppType); var appKey = new AppKey(options.AppName, appType); return(appKey); }
private async Task completeVersion(AppKey appKey, string repoOwner, string repoName) { if (hostEnv.IsProduction()) { var versionOptions = new VersionToolOptions(); versionOptions.CommandCompleteVersion(repoOwner, repoName, appKey.Name.Value, appKey.Type.DisplayText); await runVersionTool(versionOptions); } }
private async Task <VersionToolOutput> retrieveCurrentVersion(AppKey appKey) { var versionOptions = new VersionToolOptions(); versionOptions.CommandGetCurrentVersion(appKey.Name.Value, appKey.Type.DisplayText); var versionResult = await runVersionTool(versionOptions); var currentVersion = versionResult.Data <VersionToolOutput>(); return(currentVersion); }
private async Task <VersionToolOutput> beginPublish(AppKey appKey) { Console.WriteLine("Begin Publishing"); var versionOptions = new VersionToolOptions(); versionOptions.CommandBeginPublish(appKey.Name.Value, appKey.Type.DisplayText); var result = await runVersionTool(versionOptions); var output = result.Data <VersionToolOutput>(); return(output); }
private static async Task <VersionToolOutput> retrieveVersion(AppKey appKey) { var versionOptions = new VersionToolOptions(); versionOptions.CommandGetVersion(); versionOptions.AppName = appKey.Name.DisplayText; versionOptions.AppType = appKey.Type.DisplayText; var versionResult = await runVersionTool(versionOptions); var currentVersion = versionResult.Data <VersionToolOutput>(); return(currentVersion); }
private async Task <VersionToolOutput> getVersionKey(AppKey appKey) { var versionOptions = new VersionToolOptions(); versionOptions.CommandGetVersion(); versionOptions.AppName = appKey.Name.Value; versionOptions.AppType = appKey.Type.DisplayText; var result = await runVersionTool(versionOptions); var output = result.Data <VersionToolOutput>(); return(output); }
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); } }
private async Task <WinProcessResult> runVersionTool(VersionToolOptions options) { var path = Path.Combine ( getXtiDir(), "Tools", "XTI_VersionTool", "XTI_VersionTool.exe" ); var result = await new XtiProcess(path) .UseProductionEnvironment() .WriteOutputToConsole() .AddConfigOptions(options) .Run(); result.EnsureExitCodeIsZero(); return(result); }
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 gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName); var defaultBranchName = await gitHubRepo.DefaultBranchName(); if (!currentBranchName.Equals(defaultBranchName, StringComparison.OrdinalIgnoreCase)) { throw new ArgumentException($"Current branch '{currentBranchName}' is not the default branch '{defaultBranchName}'"); } var versionType = AppVersionType.Values.Value(options.VersionType); var newVersionResult = await hubApi.AppRegistration.NewVersion.Execute(new NewVersionRequest { AppKey = options.AppKey(), VersionType = versionType }); var version = newVersionResult.Data; var gitVersion = new XtiGitVersion(version.VersionType.DisplayText, version.VersionKey); await gitHubRepo.CreateNewVersion(gitVersion); var newVersionBranchName = gitVersion.BranchName(); gitRepo.CheckoutBranch(newVersionBranchName.Value); }
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); }
public async Task Setup() { var host = Host.CreateDefaultBuilder() .ConfigureServices ( (hostContext, services) => { services.AddFakesForHubWebApp(hostContext.Configuration); services.AddScoped <GitFactory, FakeGitFactory>(); services.AddScoped <VersionCommandFactory>(); services.AddFakeSecretCredentials(); } ) .Build(); var scope = host.Services.CreateScope(); sp = scope.ServiceProvider; var setup = sp.GetService <IAppSetup>(); await setup.Run(AppVersionKey.Current); var appFactory = sp.GetService <AppFactory>(); App = await appFactory.Apps().App(HubInfo.AppKey); Options = new VersionToolOptions(); Options.CommandNewVersion ( HubInfo.AppKey.Name.Value, HubInfo.AppKey.Type.DisplayText, AppVersionType.Values.Patch.DisplayText, "JasonBenfield", "XTI_App" ); var gitFactory = sp.GetService <GitFactory>(); var gitHubRepo = await gitFactory.CreateGitHubRepo("JasonBenfield", "XTI_App"); var defaultBranchName = await gitHubRepo.DefaultBranchName(); var gitRepo = await gitFactory.CreateGitRepo(); gitRepo.CheckoutBranch(defaultBranchName); }
private static async Task <WinProcessResult> runVersionTool(VersionToolOptions versionOptions) { var versionToolProcess = new XtiProcess ( Path.Combine ( getXtiDir(), "Tools", "XTI_VersionTool", "XTI_VersionTool.exe" ) ); versionToolProcess.UseProductionEnvironment(); versionToolProcess.AddConfigOptions(versionOptions); var result = await versionToolProcess.Run(); result.EnsureExitCodeIsZero(); return(result); }
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 currentVersion = await hubApi.AppRegistration.GetVersion.Invoke(new GetVersionRequest { AppKey = options.AppKey(), VersionKey = AppVersionKey.Current }); var output = new VersionOutput(); output.Output(currentVersion, options.OutputPath); }
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}"); } }
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 }); }
private static async Task <VersionToolOutput> retrieveCurrentVersion(AppKey appKey) { var versionToolProcess = new XtiProcess ( Path.Combine ( getXtiDir(), "Tools", "XTI_VersionTool", "XTI_VersionTool.exe" ) ); versionToolProcess.UseProductionEnvironment(); var versionOptions = new VersionToolOptions(); versionOptions.CommandGetCurrentVersion(appKey.Name.Value, appKey.Type.DisplayText); versionToolProcess.AddConfigOptions(versionOptions); var versionResult = await versionToolProcess.Run(); var currentVersion = versionResult.Data <VersionToolOutput>(); return(currentVersion); }