Skip to content

Commit

Permalink
Set Naming strategy to KebabCaseNamingStrategy
Browse files Browse the repository at this point in the history
  • Loading branch information
coenm committed Aug 9, 2023
1 parent a8accdb commit 527ae13
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionDeserializers;
Expand Down Expand Up @@ -67,6 +68,7 @@ public sealed class EvaluatedPropertyAttribute : Attribute
/// Attribute the textual type of the repository action.
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
[MeansImplicitUse]
public sealed class RepositoryActionAttribute : Attribute
{
public RepositoryActionAttribute(string type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Deserialization;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionDeserializers;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data;

Expand All @@ -14,6 +15,10 @@ public class JsonDynamicRepositoryActionDeserializer
private readonly ActionDeserializerComposition _deserializers;
private static readonly JsonSerializer _jsonSerializer = new()
{
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new KebabCaseNamingStrategy(),
},
Converters =
{
new BoolToStringJsonConverter(),
Expand All @@ -24,6 +29,7 @@ public class JsonDynamicRepositoryActionDeserializer
CommentHandling = CommentHandling.Ignore,
};


public JsonDynamicRepositoryActionDeserializer(ActionDeserializerComposition deserializers)
{
_deserializers = deserializers ?? throw new ArgumentNullException(nameof(deserializers));
Expand Down

This file was deleted.

5 changes: 1 addition & 4 deletions src/RepoM.Plugin.AzureDevOps/AzureDevOpsPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ private async Task ExtractAndRegisterConfiguration(Container container, IPackage
private static void RegisterServices(Container container)
{
container.RegisterDefaultRepositoryActionDeserializerForType<RepositoryActionAzureDevOpsCreatePullRequestsV1>();
// container.Collection.Append<IActionDeserializer, ActionAzureDevOpsCreatePullRequestsV1Deserializer>(Lifestyle.Singleton);

// container.RegisterDefaultRepositoryActionDeserializerForType<RepositoryActionAzureDevOpsGetPullRequestsV1>();
container.Collection.Append<IActionDeserializer, ActionAzureDevOpsGetPullRequestsV1Deserializer>(Lifestyle.Singleton);
container.RegisterDefaultRepositoryActionDeserializerForType<RepositoryActionAzureDevOpsGetPullRequestsV1>();

container.Collection.Append<IActionToRepositoryActionMapper, ActionAzureDevOpsCreatePullRequestsV1Mapper>(Lifestyle.Singleton);
container.Collection.Append<IActionToRepositoryActionMapper, ActionAzureDevOpsGetPullRequestsV1Mapper>(Lifestyle.Singleton);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
{
"type": "browse-repository@1",
"name": "fo true",
"FirstOnly": true
"first-only": true
},
{
"type": "browse-repository@1",
"name": "fo false",
"FirstOnly": false
"first-only": false
},
{
"type": "browse-repository@1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace RepoM.Plugin.AzureDevOps.Tests.ActionProvider;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Deserialization;
using RepoM.Api.Tests.IO.ModuleBasedRepositoryActionProvider;
using RepoM.Plugin.AzureDevOps.ActionProvider;
using RepoM.Plugin.AzureDevOps.ActionProvider.Options;
using VerifyTests;
using VerifyXunit;
Expand All @@ -28,7 +27,7 @@ public class AzureDevOpsGetPullRequestsV1Test

public AzureDevOpsGetPullRequestsV1Test()
{
_sutJson = CreateWithDeserializer(new ActionAzureDevOpsGetPullRequestsV1Deserializer());
_sutJson = CreateWithDeserializer(new DefaultActionDeserializer<RepositoryActionAzureDevOpsGetPullRequestsV1>());
_sutYaml = new YamlDynamicRepositoryActionDeserializer(_sutJson);

_testFileSettings = new EasyTestFileSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ repository-actions:
actions:
# Create PR
- type: azure-devops-create-prs@1
projectId: ''
toBranch: develop
reviewerIds:
project-id: ''
to-branch: develop
reviewer-ids:
- "GUID"

# Create PR with auto-complete enabled
- type: azure-devops-create-prs@1
projectId: ''
toBranch: develop
reviewerIds:
project-id: ''
to-branch: develop
reviewer-ids:
- "GUID"
autoComplete:
auto-complete:
enabled: true
mergeStrategy: "Squash"
merge-strategy: "Squash"

# Create PR with all settings
- type: azure-devops-create-prs@1
projectId: ''
project-id: ''
title: 'Create PR'
# When no prTitle provided it will be generated based on convention.
# When no pr-title provided it will be generated based on convention.
# Title will be the last part of the branchname split on '/'.
# For example: feature/testBranch will result in a PR title of 'testBranch'.
prTitle: 'PR title'
toBranch: develop
reviewerIds:
pr-title: 'PR title'
to-branch: develop
reviewer-ids:
- "GUID"
draftPr: true
includeWorkItems: true
openInBrowser: false
autoComplete:
draft-pr: true
include-work-items: true
open-in-browser: false
auto-complete:
enabled: true
mergeStrategy: "NoFastForward" # You can choose from: "NoFastForward", "Squash", "Rebase" and "RebaseMerge"
deleteSourceBranch: true
transitionWorkItems: true
merge-strategy: "NoFastForward" # You can choose from: "NoFastForward", "Squash", "Rebase" and "RebaseMerge"
deleteSource-branch: true
transition-work-items: true

# end-snippet
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ namespace RepoM.Plugin.AzureDevOps.Tests.TestFramework;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.ActionDeserializers;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Data;
using RepoM.Api.IO.ModuleBasedRepositoryActionProvider.Deserialization;
using RepoM.Plugin.AzureDevOps.ActionProvider;
using RepoM.Plugin.AzureDevOps.ActionProvider.Options;

internal static class DynamicRepositoryActionDeserializerFactory
Expand All @@ -16,7 +15,7 @@ public static JsonDynamicRepositoryActionDeserializer Create()
new IActionDeserializer[]
{
new DefaultActionDeserializer<RepositoryActionAzureDevOpsCreatePullRequestsV1>(),
new ActionAzureDevOpsGetPullRequestsV1Deserializer(),
new DefaultActionDeserializer<RepositoryActionAzureDevOpsGetPullRequestsV1>(),
}));
}

Expand Down

0 comments on commit 527ae13

Please sign in to comment.