Skip to content

Commit bf07a59

Browse files
committed
Fix another break caused by upgrading from beta 1
1 parent 6936d49 commit bf07a59

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

src/TfvcMigrator.Tests/EntryPointTests.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,45 @@ public static class EntryPointTests
66
public static async Task No_System_CommandLine_failure_for_minimal_arguments()
77
{
88
var arguments = await CommandVerifier.VerifyArgumentsAsync(async () =>
9-
await Program.Main(new[] { "http://someurl", "$/SomePath", "--authors", "authors.txt" }));
9+
await Program.Main(new[]
10+
{
11+
"http://someurl",
12+
"$/SomePath",
13+
"--authors", "authors.txt",
14+
}));
1015

1116
arguments[0].ShouldBe(new Uri("http://someurl"));
1217
arguments[1].ShouldBe("$/SomePath");
1318
arguments[2].ShouldBe("authors.txt");
1419
}
20+
21+
[Test]
22+
public static async Task No_System_CommandLine_failure_for_all_arguments()
23+
{
24+
var arguments = await CommandVerifier.VerifyArgumentsAsync(async () =>
25+
await Program.Main(new[]
26+
{
27+
"http://someurl",
28+
"$/SomePath",
29+
"--authors", "authors.txt",
30+
"--out-dir", "somedir",
31+
"--min-changeset", "42",
32+
"--max-changeset", "43",
33+
"--root-path-changes", "CS1234:$/New/Path", "CS1235:$/Another/Path",
34+
"--pat", "somepat",
35+
}));
36+
37+
arguments[0].ShouldBe(new Uri("http://someurl"));
38+
arguments[1].ShouldBe("$/SomePath");
39+
arguments[2].ShouldBe("authors.txt");
40+
arguments[3].ShouldBe("somedir");
41+
arguments[4].ShouldBe(42);
42+
arguments[5].ShouldBe(43);
43+
arguments[6].ShouldBeOfType<ImmutableArray<RootPathChange>>().ShouldBe(new[]
44+
{
45+
new RootPathChange(1234, "$/New/Path"),
46+
new RootPathChange(1235, "$/Another/Path"),
47+
});
48+
arguments[7].ShouldBe("somepat");
49+
}
1550
}

src/TfvcMigrator/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public static Task Main(string[] args)
3131
parseArgument: result => result.Tokens.Select(token => ParseRootPathChange(token.Value)).ToImmutableArray())
3232
{
3333
Arity = ArgumentArity.OneOrMore,
34+
AllowMultipleArgumentsPerToken = true,
3435
Description = "Followed by one or more arguments with the format CS1234:$/New/Path. Changes the path that is mapped as the Git repository root to a new path during a specified changeset.",
3536
},
3637
new Option<string?>("--pat") { Description = "Optional PAT, required to access TFVC repositories hosted on Azure DevOps Services. If not provided Default Client Credentials will be used, these are only suitable for on-premise TFS/Azure DevOps Server." },

src/TfvcMigrator/RootPathChange.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace TfvcMigrator;
22

33
[DebuggerDisplay("{ToString(),nq}")]
4-
public sealed class RootPathChange
4+
public sealed class RootPathChange : IEquatable<RootPathChange?>
55
{
66
public RootPathChange(int changeset, string newSourceRootPath)
77
{
@@ -18,5 +18,22 @@ public RootPathChange(int changeset, string newSourceRootPath)
1818
public int Changeset { get; }
1919
public string NewSourceRootPath { get; }
2020

21+
public override bool Equals(object? obj)
22+
{
23+
return Equals(obj as RootPathChange);
24+
}
25+
26+
public bool Equals(RootPathChange? other)
27+
{
28+
return other != null &&
29+
Changeset == other.Changeset &&
30+
NewSourceRootPath == other.NewSourceRootPath;
31+
}
32+
33+
public override int GetHashCode()
34+
{
35+
return HashCode.Combine(Changeset, NewSourceRootPath);
36+
}
37+
2138
public override string ToString() => $"CS{Changeset}:{NewSourceRootPath}";
2239
}

0 commit comments

Comments
 (0)