Skip to content

Commit 8f16384

Browse files
committed
fix(IPullRequest): update property accessors to use TryGetValue
- Update `DeleteLocalOnSuccess` property to use `TryGetValue<bool?>(() => DeleteLocalOnSuccess) ?? false` - Update `Draft` property to use `TryGetValue<bool?>(() => Draft) ?? false` - Update `Title` property to use `TryGetValue(() => Title)` and switch expression for branch type - Update `Description` property to use `TryGetValue(() => Description)` - Add `FinishChore` method to implement `IDoChoreWorkflow` interface
1 parent 406d092 commit 8f16384

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99
### 🛠️ Fixes
1010
- Fixed incorrect source branch name when creating a `chore` branch ([#202](https://github.com/candoumbe/pipelines/issues/202))
11+
- Fixed the behavior of `chore` command when running from a `chore/*` branch : the command will now properly end the `chore` workflow.
1112

1213
### 🚀 New features
1314
- Added `IDoChoreWorkflow` to `IGitFlow` and `IGitHubFlow`: this enable the `chore` target on those workflows

src/Candoumbe.Pipelines/Components/GitHub/IGitFlowWithPullRequest.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,7 @@ static void OpenUrl(string url)
143143
}
144144
}
145145
}
146+
147+
/// <inheritdoc />
148+
async ValueTask IDoChoreWorkflow.FinishChore() => await FinishFeature();
146149
}

src/Candoumbe.Pipelines/Components/GitHub/IGitHubFlowWithPullRequest.cs

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ namespace Candoumbe.Pipelines.Components.GitHub
1818
/// <summary>
1919
/// This interface adds a target to open a pull request
2020
/// </summary>
21-
public interface IGitHubFlowWithPullRequest : IGitHubFlow, IHaveGitHubRepository
21+
public interface IGitHubFlowWithPullRequest : IGitHubFlow, IPullRequest
2222
{
2323
/// <summary>
2424
/// The title of the PR that will be created
2525
/// </summary>
2626
[Parameter("Title that will be used when creating a PR")]
27-
string Title => TryGetValue(() => Title) ?? ((GitRepository.IsOnFeatureBranch(), GitRepository.IsOnReleaseBranch(), GitRepository.IsOnHotfixBranch()) switch
27+
string IPullRequest.Title => TryGetValue(() => Title) ?? ((GitRepository.IsOnFeatureBranch(), GitRepository.IsOnReleaseBranch(), GitRepository.IsOnHotfixBranch()) switch
2828
{
2929
(true, _, _) => $"✨ {GitRepository.Branch?.Replace($"{FeatureBranchPrefix}/", string.Empty).ToTitleCase()}",
3030
(_, _, true) => $"🛠️ {GitRepository.Branch?.Replace($"{HotfixBranchPrefix}/", string.Empty).ToTitleCase()}",
@@ -42,25 +42,7 @@ public interface IGitHubFlowWithPullRequest : IGitHubFlow, IHaveGitHubRepository
4242
/// Description of the pull request
4343
/// </summary>
4444
[Parameter("Description of the pull request")]
45-
string Description => TryGetValue(() => Description) ?? this.As<IHaveChangeLog>()?.ReleaseNotes;
46-
47-
/// <summary>
48-
/// Should the local branch be deleted after the pull request was created successfully ?
49-
/// </summary>
50-
[Parameter("Should the local branch be deleted after the pull request was created successfully ?")]
51-
public bool DeleteLocalOnSuccess { get; }
52-
53-
/// <summary>
54-
/// Defines, when set to <see langword="true"/>, to open the pull request as draft.
55-
/// </summary>
56-
[Parameter("Indicates to open the pull request as 'draft'")]
57-
public bool Draft { get; }
58-
59-
/// <summary>
60-
/// The issue ID for witch pull request will be created.
61-
/// </summary>
62-
[Parameter("Issues that will be closed once the pull request is merged.")]
63-
uint[] Issues => TryGetValue(() => Issues) ?? [];
45+
string IPullRequest.Description => TryGetValue(() => Description) ?? this.As<IHaveChangeLog>()?.ReleaseNotes;
6446

6547
///<inheritdoc/>
6648
async ValueTask IDoFeatureWorkflow.FinishFeature()
@@ -183,5 +165,8 @@ static void OpenUrl(string url)
183165
}
184166
}
185167
}
168+
169+
/// <inheritdoc />
170+
async ValueTask IDoChoreWorkflow.FinishChore() => await FinishFeature();
186171
}
187172
}

src/Candoumbe.Pipelines/Components/GitHub/IPullRequest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ public interface IPullRequest : IHaveGitHubRepository
2424
/// Should the local branch be deleted after the pull request was created successfully ?
2525
/// </summary>
2626
[Parameter("Should the local branch be deleted after the pull request was created successfully ?")]
27-
bool DeleteLocalOnSuccess => false;
27+
bool DeleteLocalOnSuccess => TryGetValue<bool?>(() => DeleteLocalOnSuccess) ?? false;
2828

2929
/// <summary>
3030
/// Defines, when set to <see langword="true"/>, to open the pull request as draft.
3131
/// </summary>
3232
[Parameter("Indicates to open the pull request as 'draft'")]
33-
bool Draft => false;
33+
bool Draft => TryGetValue<bool?>(() => Draft) ?? false;
3434

3535
/// <summary>
3636
/// The issue ID for witch pull request will be created.
3737
/// </summary>
3838
[Parameter("Issues that will be closed once the pull request is completed.")]
3939
uint[] Issues => TryGetValue(() => Issues) ?? [];
4040
}
41-
}
41+
}

0 commit comments

Comments
 (0)