Skip to content

Commit

Permalink
Display SourceDirectory property in subscription list (#3349)
Browse files Browse the repository at this point in the history
  • Loading branch information
premun authored Feb 28, 2024
1 parent f2b61b3 commit ad8ff71
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/Maestro/Maestro.DataProviders/SqlBarClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public async Task<Subscription> GetSubscriptionAsync(Guid subscriptionId)
sub.SourceRepository,
sub.TargetRepository,
sub.TargetBranch,
sub.PullRequestFailureNotificationTags,
sub.SourceDirectory,
sub.PullRequestFailureNotificationTags,
sub.ExcludedAssets.Select(s => s.Filter).ToImmutableList());
}

Expand Down
42 changes: 24 additions & 18 deletions src/Microsoft.DotNet.Darc/Darc/Helpers/UxHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,26 +201,32 @@ public static string GetMergePoliciesDescription(IEnumerable<MergePolicy> mergeP

public static string GetTextSubscriptionDescription(Subscription subscription, IEnumerable<MergePolicy> mergePolicies = null)
{

var subInfo = new StringBuilder();
subInfo.AppendLine($"{subscription.SourceRepository} ({subscription.Channel.Name}) ==> '{subscription.TargetRepository}' ('{subscription.TargetBranch}')");
subInfo.AppendLine($" - Id: {subscription.Id}");
subInfo.AppendLine($" - Update Frequency: {subscription.Policy.UpdateFrequency}");
subInfo.AppendLine($" - Enabled: {subscription.Enabled}");
subInfo.AppendLine($" - Batchable: {subscription.Policy.Batchable}");
subInfo.AppendLine($" - PR Failure Notification tags: {subscription.PullRequestFailureNotificationTags}");
subInfo.AppendLine($" - Source-enabled: {subscription.SourceEnabled}");

string excludedAssets;
if (subscription.ExcludedAssets.Any())
var subInfo = new StringBuilder($"""
{subscription.SourceRepository} ({subscription.Channel.Name}) ==> '{subscription.TargetRepository}' ('{subscription.TargetBranch}')
- Id: {subscription.Id}
- Update Frequency: {subscription.Policy.UpdateFrequency}
- Enabled: {subscription.Enabled}
- Batchable: {subscription.Policy.Batchable}
- PR Failure Notification tags: {subscription.PullRequestFailureNotificationTags}
- Source-enabled: {subscription.SourceEnabled}
""");

if (subscription.SourceEnabled)
{
excludedAssets = string.Join(Environment.NewLine + " - ", [string.Empty, ..subscription.ExcludedAssets]);
}
else
{
excludedAssets = " []";
subInfo.AppendLine($" - Source Directory: {subscription.SourceDirectory}");

string excludedAssets;
if (subscription.ExcludedAssets.Any())
{
excludedAssets = string.Join(Environment.NewLine + " - ", [string.Empty, .. subscription.ExcludedAssets]);
}
else
{
excludedAssets = " []";
}
subInfo.AppendLine($" - Excluded Assets:{excludedAssets}");
}
subInfo.AppendLine($" - Excluded Assets:{excludedAssets}");

IEnumerable<MergePolicy> policies = mergePolicies ?? subscription.Policy.MergePolicies;
subInfo.Append(GetMergePoliciesDescription(policies, " "));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
- Batchable: False
- PR Failure Notification tags:
- Source-enabled: False
- Excluded Assets: []
- Merge Policies: []
source2 (name) ==> 'target2' ('test')
- Id: 00000000-0000-0000-0000-000000000000
- Update Frequency: EveryDay
- Enabled: True
- Batchable: False
- PR Failure Notification tags:
- Source-enabled: False
- Source-enabled: True
- Source Directory: repo-name
- Excluded Assets: []
- Merge Policies: []
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
- Batchable: False
- PR Failure Notification tags:
- Source-enabled: False
- Excluded Assets: []
- Merge Policies: []
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public async Task GetSubscriptionsOperationTests_ExecuteAsync_returns_json()
[Test]
public async Task GetSubscriptionsOperationTests_ExecuteAsync_returns_sorted_text()
{
Subscription subscription1 = new(Guid.Empty, true, false, "source2", "target2", "test", string.Empty, null, ImmutableList<string>.Empty)
Subscription subscription1 = new(Guid.Empty, true, true, "source2", "target2", "test", "repo-name", null, ImmutableList<string>.Empty)
{
Channel = new(id: 1, name: "name", classification: "classification"),
Policy = new(batchable: false, updateFrequency: UpdateFrequency.EveryDay)
Expand Down

0 comments on commit ad8ff71

Please sign in to comment.