diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json
index 503efce..52b5f1f 100644
--- a/.nuke/build.schema.json
+++ b/.nuke/build.schema.json
@@ -18,10 +18,18 @@
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
+ "DeleteLocalOnSuccess": {
+ "type": "boolean",
+ "description": "Should the local branch be deleted after the pull request was created successfully ?"
+ },
"Description": {
"type": "string",
"description": "Description of the pull request"
},
+ "Draft": {
+ "type": "boolean",
+ "description": "Indicates to open the pull request as 'draft'"
+ },
"GitHubToken": {
"type": "string",
"description": "Token used to create a new release in GitHub",
@@ -56,6 +64,13 @@
"type": "boolean",
"description": "Ignore unreachable sources during Restore"
},
+ "Issues": {
+ "type": "array",
+ "description": "Issues that will be closed once the pull request is merged",
+ "items": {
+ "type": "string"
+ }
+ },
"Major": {
"type": "boolean",
"description": "Hint to create a major release"
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 35bd085..a0d37bb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,7 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Moved `ICreateGitHubRelease` to `Candoumbe.Pipelines.Components.GitHub` namespace
### New features
-
+- Added `IPullRequest.Issues` parameter which allows to specify issues a pull request fixes ([#9](https://github.com/candoumbe/pipelines/issues/9))
- Added execution of `IPublish.Publish` target on `integration` workflow
- Added `IHaveReport` component that can be used by pipelines that output reports of any kind (code coverage, performance tests, ...)
- Added `IUnitTest.UnitTestsResultsDirectory` which defines where to output unit test result files
@@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `IBenchmark.BenchmarkTestResultsDirectory` which defines where to output benchmarks test result files
- Added `IPullRequest` component which extends `IGitFlow` and create pull requests instead or merging back to `develop` (respectiveley `main`) when finishing a feature / coldfix (resp. release / hotfix) branch.
- Added `IHaveGitHubRepository` which extends `IHaveGitRepository` and specific properties related to GitHub repositories.
+- Promoted `IPullRequest.DeleteLocalOnSuccess` as parameter
+- Promoted `IPullRequest.Draft` as parameter
### Fixes
diff --git a/src/Candoumbe.Pipelines/Components/GitHub/IPullRequest.cs b/src/Candoumbe.Pipelines/Components/GitHub/IPullRequest.cs
index 315ab69..d69ed4c 100644
--- a/src/Candoumbe.Pipelines/Components/GitHub/IPullRequest.cs
+++ b/src/Candoumbe.Pipelines/Components/GitHub/IPullRequest.cs
@@ -5,6 +5,9 @@
using Octokit;
using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
using System.Threading.Tasks;
using static Nuke.Common.Tools.Git.GitTasks;
@@ -46,7 +49,8 @@ public interface IPullRequest : IGitFlow, IHaveGitHubRepository
///
/// Should the local branch be deleted after the pull request was created successfully ?
///
- public bool DeleteLocalOnSuccess => false;
+ [Parameter("Should the local branch be deleted after the pull request was created successfully ?")]
+ bool DeleteLocalOnSuccess => false;
///
/// Defines, when set to , to open the pull request as draft.
@@ -57,12 +61,16 @@ public interface IPullRequest : IGitFlow, IHaveGitHubRepository
///
/// The issue ID for witch pull request will be created.
///
- [Parameter("The issue ID for witch pull request will be created.")]
- uint? Issue => null;
+ [Parameter("Issues that will be closed once the pull request is merged.")]
+ uint[] Issues => Array.Empty();
///
async ValueTask IGitFlow.FinishFeature()
{
+ string linkToIssueKeyWord = Issues.AtLeastOnce()
+ ? string.Join(',', Issues.Select(issueNumber => $"Resolves #{issueNumber}").ToArray())
+ : null;
+
// Push to the remote branch
GitPushToRemote();
@@ -87,13 +95,17 @@ async ValueTask IGitFlow.FinishFeature()
NewPullRequest newPullRequest = new(title, branchName, DevelopBranch)
{
Draft = Draft,
- Body = Description
+ Body = linkToIssueKeyWord is not null
+ ? $"{Description}{Environment.NewLine}{Environment.NewLine}{linkToIssueKeyWord}"
+ : Description
};
PullRequest pullRequest = await gitHubClient.PullRequest.Create(owner, repositoryName, newPullRequest);
- Information("PR {PullRequestUrl} created successfully", pullRequest.HtmlUrl);
DeleteLocalBranchIf(DeleteLocalOnSuccess, branchName, switchToBranchName: DevelopBranch);
+ Information("PR {PullRequestUrl} created successfully", pullRequest.HtmlUrl);
+
+ Process.Start(pullRequest.HtmlUrl);
}
}
@@ -140,8 +152,15 @@ async ValueTask IGitFlow.FinishReleaseOrHotfix()
{
Credentials = new Credentials(token)
};
- NewPullRequest newPullRequest = new(Title, GitRepository.Branch, MainBranchName);
-
+ NewPullRequest newPullRequest = new(Title, GitRepository.Branch, MainBranchName)
+ {
+ Draft = Draft,
+ Body = Issues.AtLeastOnce() switch
+ {
+ true => $"{Description}{Environment.NewLine}{Environment.NewLine}",
+ _ => Description
+ }
+ };
PullRequest pullRequest = await gitHubClient.PullRequest.Create(GitRepository.GetGitHubOwner(), repositoryName, newPullRequest);
Information("PR {PullRequestUrl} created successfully", pullRequest.HtmlUrl);