-
Notifications
You must be signed in to change notification settings - Fork 651
NullReferenceException when using dynamic repositories #782
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
Comments
I was seeing exactly the same symptoms earlier; ended up rolling back to v3.3.0 from Chocolatey feed to get our builds working again. PR is unlikely from me as well for similar reasons. |
No problems guys, thanks for the report. I will fix as soon as I get a chance. |
In version 3.5.3 I get the following error instead:
|
@rubenmamo Yes, the |
@asbjornu no the folder does not have a .git directory. I'm using dynamic repositories in team city and tried to debug it by using the source code, I call GitVersion from the build agent and pass the /url /b /c /u /p parameters to it. What seems to be happening is that when GitPreparer.GetDotGitDirectory() is called from execute core in these cases DynamicGitRepositoryPath is not initialised and hence the following code is skipped
As @laped mentioned in the original comment the problem seems to be a missing call to gitPreparer.Initialise(false, targetBranch); in ExecuteCore, however this seems to do a number of things and hence might cause additional issues? I'm happy to add the missing method call and create a PR |
I added Pull Request #874 which should resolve this. |
#874 was released with version 3.6.0 |
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
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:
to this:
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.
The text was updated successfully, but these errors were encountered: