Skip to content

Commit a502300

Browse files
committed
Fix confusing ".." in log filenames for local deploys.
1 parent ee7af54 commit a502300

4 files changed

Lines changed: 32 additions & 14 deletions

File tree

PSql.Deploy.Engine/Core/Target.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public Target(
5454

5555
ServerDisplayName
5656
= serverDisplayName
57-
?? builder.DataSource.NullIfEmpty()
57+
?? builder.DataSource.NullIfEmpty().NullIf(".")
5858
?? "local";
5959

6060
DatabaseDisplayName

PSql.Deploy.Engine/Utilities/StringExtensions.cs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Copyright Subatomix Research Inc.
22
// SPDX-License-Identifier: MIT
33

4-
using System.Diagnostics.CodeAnalysis;
5-
using System.Text;
6-
74
namespace PSql.Deploy;
85

96
/// <summary>
@@ -26,7 +23,7 @@ public static bool IsNullOrEmpty([NotNullWhen(false)] this string? s)
2623
=> string.IsNullOrEmpty(s);
2724

2825
/// <summary>
29-
/// Replaces an empty string with <see langword="null"/>.
26+
/// Replaces the string with <see langword="null"/> if it is empty.
3027
/// </summary>
3128
/// <param name="s">
3229
/// The string to transform.
@@ -36,7 +33,28 @@ public static bool IsNullOrEmpty([NotNullWhen(false)] this string? s)
3633
/// <paramref name="s"/> otherwise.
3734
/// </returns>
3835
public static string? NullIfEmpty(this string? s)
39-
=> string.IsNullOrEmpty(s) ? null : s;
36+
=> s.NullIf(string.Empty);
37+
38+
/// <summary>
39+
/// Replaces the string with <see langword="null"/> if it is equal to the
40+
/// specified string.
41+
/// </summary>
42+
/// <param name="s">
43+
/// The string to transform.
44+
/// </param>
45+
/// <param name="nullish">
46+
/// The string against which to compare <paramref name="s"/>.
47+
/// </param>
48+
/// <returns>
49+
/// <see langword="null"/>
50+
/// if <paramref name="s"/> is equal to <paramref name="nullish"/>;
51+
/// <paramref name="s"/>
52+
/// otherwise.
53+
/// </returns>
54+
/// This method performs a case-sensitive ordinal comparison.
55+
/// <remarks>
56+
public static string? NullIf(this string? s, string? nullish)
57+
=> s == nullish ? null : s;
4058

4159
/// <summary>
4260
/// Escapes the string for inclusing in a SQL string literal.

PSql.Deploy.Tests/Integration/InvokeSqlMigrationsCommandTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ void ShouldBeMigrations(int n, MigrationState state)
7777
ShouldBeMigrations(3, MigrationState.AppliedPost);
7878
ShouldBeMigrations(6, MigrationState.AppliedPost);
7979

80-
File.ReadAllText("..PSqlDeployTestA.0_Pre.log" ).ShouldNotBeNullOrEmpty();
81-
File.ReadAllText("..PSqlDeployTestA.1_Core.log").ShouldNotBeNullOrEmpty();
82-
File.ReadAllText("..PSqlDeployTestA.2_Post.log").ShouldNotBeNullOrEmpty();
83-
File.ReadAllText("..PSqlDeployTestB.0_Pre.log" ).ShouldNotBeNullOrEmpty();
84-
File.ReadAllText("..PSqlDeployTestB.1_Core.log").ShouldNotBeNullOrEmpty();
85-
File.ReadAllText("..PSqlDeployTestB.2_Post.log").ShouldNotBeNullOrEmpty();
80+
File.ReadAllText("local.PSqlDeployTestA.0_Pre.log" ).ShouldNotBeNullOrEmpty();
81+
File.ReadAllText("local.PSqlDeployTestA.1_Core.log").ShouldNotBeNullOrEmpty();
82+
File.ReadAllText("local.PSqlDeployTestA.2_Post.log").ShouldNotBeNullOrEmpty();
83+
File.ReadAllText("local.PSqlDeployTestB.0_Pre.log" ).ShouldNotBeNullOrEmpty();
84+
File.ReadAllText("local.PSqlDeployTestB.1_Core.log").ShouldNotBeNullOrEmpty();
85+
File.ReadAllText("local.PSqlDeployTestB.2_Post.log").ShouldNotBeNullOrEmpty();
8686
}
8787

8888
[Test]

PSql.Deploy.Tests/Integration/InvokeSqlSeedCommandIntegrationTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public void Invoke()
3333

3434
exception.ShouldBeNull();
3535

36-
File.ReadAllText("..PSqlDeployTestA.Typical.log").ShouldNotBeNullOrEmpty();
37-
File.ReadAllText("..PSqlDeployTestB.Typical.log").ShouldNotBeNullOrEmpty();
36+
File.ReadAllText("local.PSqlDeployTestA.Typical.log").ShouldNotBeNullOrEmpty();
37+
File.ReadAllText("local.PSqlDeployTestB.Typical.log").ShouldNotBeNullOrEmpty();
3838
}
3939

4040
[Test]

0 commit comments

Comments
 (0)