diff --git a/doc/nbgv-cli.md b/doc/nbgv-cli.md index 3c9f46af7..69b295a9f 100644 --- a/doc/nbgv-cli.md +++ b/doc/nbgv-cli.md @@ -22,8 +22,9 @@ It will also add/modify your `Directory.Build.props` file in the root of your re If scripting for running in a CI build where global impact from installing a tool is undesirable, you can localize the tool installation: ```ps1 -dotnet tool install --tool-path . nbgv +dotnet tool install --tool-path my/path nbgv ``` +> Ensure your custom path is outside of your git repository, as the `nbgv` tool doesn't support uncommited changes At this point you can launch the tool using `./nbgv` in your build script. @@ -41,7 +42,7 @@ The `prepare-release` command automates the task of branching off the main devel The `prepare-release` command supports this working model by taking care of creating the release branch and updating `version.json` on both branches. -To prepare a release, run: +To prepare a release, first ensure there is no uncommited changes in your repository then run: ```ps1 nbgv prepare-release diff --git a/src/NerdBank.GitVersioning/ReleaseManager.cs b/src/NerdBank.GitVersioning/ReleaseManager.cs index d6fd752a6..af5f9fd18 100644 --- a/src/NerdBank.GitVersioning/ReleaseManager.cs +++ b/src/NerdBank.GitVersioning/ReleaseManager.cs @@ -324,9 +324,12 @@ private LibGit2Context GetRepository(string projectDirectory) RepositoryStatus status = libgit2context.Repository.RetrieveStatus(); if (status.IsDirty) { - var changedFiles = status.OfType().ToList(); + // This filter copies the internal logic used by LibGit2 behind RepositoryStatus.IsDirty to tell if + // a repo is dirty or not + // Could be simplified if https://github.com/libgit2/libgit2sharp/pull/2004 is ever merged + var changedFiles = status.Where(file => file.State != FileStatus.Ignored && file.State != FileStatus.Unaltered).ToList(); string 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($"No uncommitted changes are allowed, but {changedFiles.Count} are present in directory '{projectDirectory}':"); this.stderr.WriteLine(changesFilesFormatted); throw new ReleasePreparationException(ReleasePreparationError.UncommittedChanges); }