Skip to content

Commit

Permalink
Supply commit messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanlerch committed Jan 20, 2025
1 parent 0836b88 commit f196b04
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 7 additions & 0 deletions source/Octopus.Server.Client/Model/ModifyRunbookCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Octopus.Client.Model
{
public class ModifyRunbookCommand : RunbookResource, ICommitCommand
{
public string ChangeDescription { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Octopus.Client.Editors.Async;
using Octopus.Client.Exceptions;
using Octopus.Client.Model;
using Octopus.Client.Serialization;

namespace Octopus.Client.Repositories.Async
{
Expand Down Expand Up @@ -117,10 +118,11 @@ public async Task<RunbookResource> Get(ProjectResource project, string gitRef, s
public async Task<RunbookResource> Create(ProjectResource project, string gitRef, RunbookResource runbook, string commitMessage, CancellationToken cancellationToken)
{
var route = $"{baseGitUri}/runbooks/v2";
var command = AppendCommitMessage(runbook, commitMessage);

return await Client.Create<RunbookResource, RunbookResource>(
route,
runbook,
command,
new
{
spaceId = project.SpaceId,
Expand All @@ -134,10 +136,11 @@ public async Task<RunbookResource> Create(ProjectResource project, string gitRef
public async Task<RunbookResource> Modify(ProjectResource project, string gitRef, RunbookResource runbook, string commitMessage, CancellationToken cancellationToken)
{
var route = $"{baseGitUri}/runbooks/{{id}}";
var command = AppendCommitMessage(runbook, commitMessage);

return await Client.Update<RunbookResource, RunbookResource>(
route,
runbook,
command,
new
{
spaceId = project.SpaceId,
Expand All @@ -162,7 +165,9 @@ await Client.Delete(
gitRef = gitRef,
slug = runbook.Id
},
null,
new {
ChangeDescription = commitMessage
},
cancellationToken
).ConfigureAwait(false);
}
Expand All @@ -184,5 +189,14 @@ public async Task<RunbookRunResource[]> Run(ProjectResource project, string gitR
cancellationToken
).ConfigureAwait(false);
}

ModifyRunbookCommand AppendCommitMessage(RunbookResource runbook, string commitMessage)
{
var json = Serializer.Serialize(runbook);
var command = Serializer.Deserialize<ModifyRunbookCommand>(json);

command.ChangeDescription = commitMessage;
return command;
}
}
}

0 comments on commit f196b04

Please # to comment.