Skip to content

More informative crash on invalid working directory #712

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 22, 2015
Merged

More informative crash on invalid working directory #712

merged 5 commits into from
Nov 22, 2015

Conversation

asbjornu
Copy link
Member

I managed to invoke GitVersion.exe with the argument showconfig instead of /showconfig and got the following exception:

Unhandled Exception: System.ComponentModel.Win32Exception: The directory name is invalid
   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at GitVersion.Helpers.ProcessHelper.Start(ProcessStartInfo startInfo)
   at GitVersion.Helpers.ProcessHelper.Run(Action`1 output, Action`1 errorOutput, TextReader input, String exe, String args, String workingDirectory, KeyValuePair`2[] environmentalVariables)
   at GitVersion.LibGitExtensions.DumpGraph(String workingDirectory, Action`1 writer, Nullable`1 max Commits)
   at GitVersion.Program.VerifyArgumentsAndRun()
   at GitVersion.Program.Main()

This PR improves this exception somewhat by at least letting the user know what the name of the directory it can't find is:

INFO [11/11/15 12:38:31:12] Working directory: showconfig
ERROR [11/11/15 12:38:31:15] An unexpected error occurred:
System.IO.DirectoryNotFoundException: Can't find the .git directory in showconfig
   at GitVersion.GitPreparer.GetProjectRootDirectory()
   at GitVersion.ExecuteCore.ExecuteGitVersion(IFileSystem fileSystem, String targetUrl, String dyna
micRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String w
orkingDirectory, String commitId)
   at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
   at GitVersion.Program.VerifyArgumentsAndRun()
INFO [11/11/15 12:38:31:15]
INFO [11/11/15 12:38:31:15] Here is the current git graph (please include in issue):
INFO [11/11/15 12:38:31:15] Showing max of 100 commits
INFO [11/11/15 12:38:31:16] ERROR: The directory showconfig doesn't exist.

I'm not sure how the process is able to advance to the exception now being thrown in GitPreparer.GetProjectRootDirectory(), but I find this a worthwile improvement nonetheless. I will attempt at writing a test for this, but please have a look at the PR and let me know if I should do anything about it.

@@ -2,26 +2,33 @@
using System.Collections.Generic;
using System.IO;
using System.Text;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this r# splitting it up? We should add the setting to stop this automatically happening (for consistency reasons) into the solution DotSettings file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I'm actually not entirely sure if it is my machine-level R# doing this or the local ("team shared") sln.DotSettings file. Either way, I agree that the local one should specify this explicitly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

Have you already read my new article? I think that's what you need at the moment, please, read it here http://describe.jamiecooks.com/e2lndncz

[email protected]

JakeGinnivan added a commit that referenced this pull request Nov 22, 2015
More informative crash on invalid working directory
@JakeGinnivan JakeGinnivan merged commit 917a646 into GitTools:master Nov 22, 2015
@asbjornu asbjornu deleted the feature/invalid-directory-crash branch November 23, 2015 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants