Skip to content

Commit 9ebc83c

Browse files
committed
Halt rather than silently overwriting the same Git path with two TFVC sources
1 parent d497828 commit 9ebc83c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/TfvcMigrator/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ pat is not null
367367
var builder = ImmutableDictionary.CreateBuilder<BranchIdentity, ImmutableArray<(string GitRepositoryPath, TfvcItem DownloadSource)>>();
368368

369369
var itemsBuilder = ImmutableArray.CreateBuilder<(string GitRepositoryPath, TfvcItem DownloadSource)>();
370+
var itemPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
370371

371372
foreach (var (branch, mapping) in branchMappingsInDependentOperationOrder)
372373
{
@@ -384,11 +385,17 @@ pat is not null
384385
}
385386

386387
if (mapping.GetGitRepositoryPath(item.Path) is { } path)
388+
{
389+
if (!itemPaths.Add(path))
390+
throw new InvalidOperationException("The same Git repository path is being added with two different TFVC sources.");
391+
387392
itemsBuilder.Add((path, item));
393+
}
388394
}
389395

390396
builder.Add(branch, itemsBuilder.ToImmutable());
391397
itemsBuilder.Clear();
398+
itemPaths.Clear();
392399
}
393400

394401
return builder.ToImmutable();

0 commit comments

Comments
 (0)