-
Notifications
You must be signed in to change notification settings - Fork 663
Description
I'm trying to use this with TeamCity, but locally I can't get it to work either when calling GitVersion with the arguments specified on this page: http://gitversion.readthedocs.org/en/latest/more-info/dynamic-repositories/
This is the command line:
GitVersion.exe /url http://gitlab/project/backend.git /u user /p password /b branchName /c ad43e4e51b9
System.NullReferenceException: Object reference not set to an instance of an object.
at GitVersion.GitPreparer.GetDotGitDirectory()
at GitVersion.ExecuteCore.ExecuteGitVersion(String targetUrl, String dynamicRepositoryLocation, Authentication authentication, String targetBranch, Boolean noFetch, String workingDirectory, String commitId)
at GitVersion.SpecifiedArgumentRunner.Run(Arguments arguments, IFileSystem fileSystem)
at GitVersion.Program.VerifyArgumentsAndRun()Which is the following line (94) in GetDotGitDirectory() when debugging locally:
var dotGitDirectory = Repository.Discover(targetPath).TrimEnd('/', '\\');
From what I can tell from looking at the code in GetDotGitDirectory(), the property IsDynamicRepository will never return true because it checks if DynamicGitRepositoryPath is empty and it is until the Initialise method has been called in GitPreparer class - which happens after the call to GetDotGitDirectory.
Even in all the unit tests the Initialise method is called first, before calling GetDotGitDirectory.
If I modify the source code in ExecuteCore.cs in line 28 (ExecuteGitVersion) from this:
var gitPreparer = new GitPreparer(targetUrl, dynamicRepositoryLocation, authentication, fetch, workingDirectory);
var dotGitDirectory = gitPreparer.GetDotGitDirectory();to this:
var gitPreparer = new GitPreparer(targetUrl, dynamicRepositoryLocation, authentication, fetch, workingDirectory);
gitPreparer.Initialise(false, targetBranch);
var dotGitDirectory = gitPreparer.GetDotGitDirectory();it works as expected.
But since I'm not familiar enough with the codebase I'm not sure it's the right fix to this problem. Maybe I'm just calling with the wrong arguments, although it doesn't look like it when reading the docs.