From adae2e533017da88ac2583c816ad40be7af9891d Mon Sep 17 00:00:00 2001 From: Sjoerdsjoerd Date: Tue, 22 Oct 2024 14:17:43 +0200 Subject: [PATCH] Implemented --- ...script_variables_repository.generated.source.md | 11 +++++++++++ .../ActionMenu/Context/RepositoryFunctions.cs | 14 ++++++++++---- .../RepoMCodeGen.generated.cs | 1 + ...ryActionAzureDevOpsCreatePullRequestV1Mapper.cs | 4 ---- ...ionAzureDevOpsCreatePullRequestV1MapperTests.cs | 13 ------------- 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/docs/mdsource/script_variables_repository.generated.source.md b/docs/mdsource/script_variables_repository.generated.source.md index 71c7bd68..1340ba67 100644 --- a/docs/mdsource/script_variables_repository.generated.source.md +++ b/docs/mdsource/script_variables_repository.generated.source.md @@ -6,6 +6,7 @@ This module contains the following methods, variables and/or constants: - [`repository.branch`](#branch) - [`repository.branches`](#branches) +- [`repository.has_local_changes`](#has_local_changes) - [`repository.is_bare`](#is_bare) - [`repository.linux_path`](#linux_path) - [`repository.local_branches`](#local_branches) @@ -35,6 +36,16 @@ Gets the current branch of the repository The name of the current branch. +## has_local_changes + +`repository.has_local_changes` + +Gets if there are local changes + +### Returns + +True when there are local changes. + ## is_bare `repository.is_bare` diff --git a/src/RepoM.ActionMenu.Core/ActionMenu/Context/RepositoryFunctions.cs b/src/RepoM.ActionMenu.Core/ActionMenu/Context/RepositoryFunctions.cs index 14e0a44d..62bb9c37 100644 --- a/src/RepoM.ActionMenu.Core/ActionMenu/Context/RepositoryFunctions.cs +++ b/src/RepoM.ActionMenu.Core/ActionMenu/Context/RepositoryFunctions.cs @@ -46,7 +46,6 @@ public RepositoryFunctions(IRepository repository) [ActionMenuContextMember("is_bare")] public bool IsBare => _repository.IsBare; - /// /// Gets the path of the repository. The path is windows or linux based (depending on the running OS) and does NOT end with a (back)slash. /// @@ -73,8 +72,8 @@ public RepositoryFunctions(IRepository repository) [ActionMenuContextMember("linux_path")] public string LinuxPath => _repository.LinuxPath; - /// - /// Gets the Location of the repository. + /// + /// Gets the Location of the repository. /// /// The path of the repository. [ActionMenuContextMember("location")] @@ -100,7 +99,14 @@ public RepositoryFunctions(IRepository repository) /// All local branches. [ActionMenuContextMember("local_branches")] public IEnumerable LocalBranches => _repository.LocalBranches; - + + /// + /// Gets if there are local changes + /// + /// True when there are local changes. + [ActionMenuContextMember("has_local_changes")] + public bool HasLocalChanges => _repository.HasLocalChanges; + /// /// Gets the remotes. /// diff --git a/src/RepoM.ActionMenu.Core/RepoMCodeGen.generated.cs b/src/RepoM.ActionMenu.Core/RepoMCodeGen.generated.cs index cbf5c66d..ed2eed77 100644 --- a/src/RepoM.ActionMenu.Core/RepoMCodeGen.generated.cs +++ b/src/RepoM.ActionMenu.Core/RepoMCodeGen.generated.cs @@ -31,6 +31,7 @@ protected sealed override void RegisterFunctions() { RegisterConstant("branch", CurrentBranch); RegisterConstant("branches", Branches); + RegisterConstant("has_local_changes", HasLocalChanges); RegisterConstant("is_bare", IsBare); RegisterConstant("linux_path", LinuxPath); RegisterConstant("local_branches", LocalBranches); diff --git a/src/RepoM.Plugin.AzureDevOps/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1Mapper.cs b/src/RepoM.Plugin.AzureDevOps/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1Mapper.cs index aaaab356..57c50087 100644 --- a/src/RepoM.Plugin.AzureDevOps/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1Mapper.cs +++ b/src/RepoM.Plugin.AzureDevOps/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1Mapper.cs @@ -24,10 +24,6 @@ public RepositoryActionAzureDevOpsCreatePullRequestV1Mapper(ILogger logger) protected override async IAsyncEnumerable MapAsync(RepositoryActionAzureDevOpsCreatePullRequestV1 action, IActionMenuGenerationContext context, IRepository repository) { - if (repository.HasLocalChanges) - { - yield break; - } var toBranch = await action.ToBranch.RenderAsync(context).ConfigureAwait(false); diff --git a/tests/RepoM.Plugin.AzureDevOps.Tests/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1MapperTests.cs b/tests/RepoM.Plugin.AzureDevOps.Tests/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1MapperTests.cs index 3da74431..d55f81f8 100644 --- a/tests/RepoM.Plugin.AzureDevOps.Tests/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1MapperTests.cs +++ b/tests/RepoM.Plugin.AzureDevOps.Tests/ActionMenu/Model/ActionMenus/CreatePullRequest/RepositoryActionAzureDevOpsCreatePullRequestV1MapperTests.cs @@ -54,19 +54,6 @@ public void Map_ShouldThrow_WhenWrongActionType() act.Should().Throw(); } - [Fact] - public async Task Map_ShouldReturnEmpty_WhenRepositoryHasLocalChanges() - { - // arrange - A.CallTo(() => _repository.HasLocalChanges).Returns(true); - - // act - List result = await _sut.MapAsync(_action, _context, _repository).ToListAsync(); - - // assert - result.Should().BeEmpty(); - } - [Fact] public async Task Map_ShouldReturnEmpty_WhenToBranchIsEmpty() {