Skip to content

Commit cb72788

Browse files
authored
fix: extend error message in case there are uncommited changes, in order to get the files which are causing the issue (#666)
* fix: extend error message in case there are uncommited changes, in order to get the files which are causing the issue This will make it possible, that the .gitignore file will be extended to exclude the temp files who are causing the issue in related repos. This fix is related to #603
1 parent 97920b7 commit cb72788

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/NerdBank.GitVersioning/ReleaseManager.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.Collections.Generic;
55
using System.IO;
6+
using System.Linq;
67
using LibGit2Sharp;
78
using Nerdbank.GitVersioning.LibGit2;
89
using Newtonsoft.Json;
@@ -408,9 +409,13 @@ private LibGit2Context GetRepository(string projectDirectory)
408409

409410

410411
// abort if there are any pending changes
411-
if (libgit2context.Repository.RetrieveStatus().IsDirty)
412+
var status = libgit2context.Repository.RetrieveStatus();
413+
if (status.IsDirty)
412414
{
413-
this.stderr.WriteLine($"Uncommitted changes in directory '{projectDirectory}'.");
415+
var changedFiles = status.OfType<StatusEntry>().ToList();
416+
var changesFilesFormatted = string.Join(Environment.NewLine, changedFiles.Select(t => $"- {t.FilePath} changed with {nameof(FileStatus)} {t.State}"));
417+
this.stderr.WriteLine($"Uncommitted changes ({changedFiles.Count}) in directory '{projectDirectory}':");
418+
this.stderr.WriteLine(changesFilesFormatted);
414419
throw new ReleasePreparationException(ReleasePreparationError.UncommittedChanges);
415420
}
416421

0 commit comments

Comments
 (0)