Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions source/Calamari.Tests/CommitToGit/CommitToGitConfigFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,20 @@ public void CreateRepositoryConfig_UsesUsernameAndPasswordFromLoadedProperties()
httpsGitConnection.Password.Should().Be("pwd-from-file");
httpsGitConnection.Uri.Value.Should().Be(new Uri("https://example.invalid/repo.git"));
}

[Test]
public void CreateRepositoryConfig_WhenDestinationPathIsMissing_DefaultsToEmptyString()
{
//Octopus server removes variables containing empty strings, thus a missing property should default to an empty string.
//Thus the TargetRepositorydestinationPath could validly be missing from the variable set, in such case, it should default to an empty string.
loader.Load<CommitToGitCustomPropertiesDto>()
.Returns(new CommitToGitCustomPropertiesDto(new UsernamePasswordGitCredentialDto("MyCred", "https://example.invalid/repo.git", "user", "pwd")));
variables.Get(SpecialVariables.Action.Git.DestinationPath).Returns((string)null);

var deployment = new RunningDeployment(null, variables);

var config = factory.CreateRepositoryConfig(deployment, loader);

config.DestinationPath.Should().Be(string.Empty);
}
}
2 changes: 1 addition & 1 deletion source/Calamari/Commands/CommitToGitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ IEnumerable<IConvention> BuildSubstituteAndCopyInputFilesConventions(
[
new DelegateInstallConvention(d =>
{
var destinationPath = repositoryConfig!.DestinationPath ?? string.Empty;
var destinationPath = repositoryConfig.DestinationPath;
var destBase = Path.Combine(clonedRepository.WorkingDirectory, destinationPath);

foreach (var package in metadataParser.GetPackageDependenciesForCopying(d))
Expand Down
3 changes: 2 additions & 1 deletion source/Calamari/CommitToGit/CommitToGitConfigFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ public CommitToGitRepositorySettings CreateRepositoryConfig(RunningDeployment de
_ => throw new NotSupportedException($"An unrecognised credential type '{properties.GitCredential.GetType().Name}' was found for '{uriAsString}'"),
};

//Note: Octopus server removes variables containing empty strings, thus a missing property should default to an empty string.
return new CommitToGitRepositorySettings(connection,
commitParameters,
variables.Get(SpecialVariables.Action.Git.DestinationPath));
variables.Get(SpecialVariables.Action.Git.DestinationPath) ?? string.Empty);
}

string EvaluateNonsensitiveExpression(string expression)
Expand Down