Skip to content

Commit

Permalink
fix: extend error message in case there are uncommited changes, in or…
Browse files Browse the repository at this point in the history
…der 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
  • Loading branch information
Lorilatschki committed Oct 7, 2021
1 parent 97920b7 commit cb72788
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/NerdBank.GitVersioning/ReleaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using LibGit2Sharp;
using Nerdbank.GitVersioning.LibGit2;
using Newtonsoft.Json;
Expand Down Expand Up @@ -408,9 +409,13 @@ private LibGit2Context GetRepository(string projectDirectory)


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

Expand Down

0 comments on commit cb72788

Please sign in to comment.