Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/mdsource/script_variables_repository.generated.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ public RepositoryFunctions(IRepository repository)
[ActionMenuContextMember("is_bare")]
public bool IsBare => _repository.IsBare;


/// <summary>
/// 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.
/// </summary>
Expand All @@ -73,8 +72,8 @@ public RepositoryFunctions(IRepository repository)
[ActionMenuContextMember("linux_path")]
public string LinuxPath => _repository.LinuxPath;

/// <summary>
/// Gets the Location of the repository.
/// <summary>
/// Gets the Location of the repository.
/// </summary>
/// <returns>The path of the repository.</returns>
[ActionMenuContextMember("location")]
Expand All @@ -100,7 +99,14 @@ public RepositoryFunctions(IRepository repository)
/// <returns>All local branches.</returns>
[ActionMenuContextMember("local_branches")]
public IEnumerable LocalBranches => _repository.LocalBranches;


/// <summary>
/// Gets if there are local changes
/// </summary>
/// <returns>True when there are local changes.</returns>
[ActionMenuContextMember("has_local_changes")]
public bool HasLocalChanges => _repository.HasLocalChanges;

/// <summary>
/// Gets the remotes.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/RepoM.ActionMenu.Core/RepoMCodeGen.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ public RepositoryActionAzureDevOpsCreatePullRequestV1Mapper(ILogger logger)

protected override async IAsyncEnumerable<UserInterfaceRepositoryActionBase> MapAsync(RepositoryActionAzureDevOpsCreatePullRequestV1 action, IActionMenuGenerationContext context, IRepository repository)
{
if (repository.HasLocalChanges)
{
yield break;
}

var toBranch = await action.ToBranch.RenderAsync(context).ConfigureAwait(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ public void Map_ShouldThrow_WhenWrongActionType()
act.Should().Throw<InvalidCastException>();
}

[Fact]
public async Task Map_ShouldReturnEmpty_WhenRepositoryHasLocalChanges()
{
// arrange
A.CallTo(() => _repository.HasLocalChanges).Returns(true);

// act
List<UserInterfaceRepositoryActionBase> result = await _sut.MapAsync(_action, _context, _repository).ToListAsync();

// assert
result.Should().BeEmpty();
}

[Fact]
public async Task Map_ShouldReturnEmpty_WhenToBranchIsEmpty()
{
Expand Down