Skip to content

[Bug] GitVersion must ensure non-null password #2247

@maxild

Description

@maxild

Describe the bug

When authenticating with github for private repo using personal access token, gitversion 5.2.4 will send invalid credentials to libgit2sharp causing exception (this is due to all the fetching, normalizing stuff in the git-preparer)

LibGit2Sharp.LibGit2SharpException: UsernamePasswordCredentials contains a null Username or Password.
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Ensure.ZeroResult(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_remote_fetch(RemoteHandle remote, IEnumerable`1 refSpecs, GitFetchOptions fetchOptions, String logMessage)
   at LibGit2Sharp.Commands.Fetch(Repository repository, String remote, IEnumerable`1 refspecs, FetchOptions options, String logMessage)
   at GitVersion.Helpers.GitRepositoryHelper.Fetch(ILog log, AuthenticationInfo authentication, Remote remote, Repository repo)
   at GitVersion.Helpers.GitRepositoryHelper.NormalizeGitDirectory(ILog log, IEnvironment environment, String gitDirectory, AuthenticationInfo authentication, Boolean noFetch, String currentBranch, Boolean isDynamicRepository)
   at GitVersion.GitPreparer.Prepare(Boolean normalizeGitDirectory, String currentBranch, Boolean shouldCleanUpRemotes)
   at GitVersion.GitVersionCalculator.CalculateVersionVariables()
   at GitVersion.ExecCommand.Execute()
   at GitVersion.GitVersionExecutor.VerifyArgumentsAndRun(Arguments arguments)

Expected Behavior

Gitversion should ensure non-null password is given to git internals.

Actual Behavior

See the stack trace above

Possible Fix

I will send PR linked to this issue in a moment.

Steps to Reproduce

Use gitversion 5.1.0+ together with

GITVERSION_REMOTE_USERNAME=access_token
GITVERSION_REMOTE_PASSWORD=empty (i.e. not used, because for instance cake will not propagate empty valued env vars)

NOTE: gitversion up until 5.0.1 used to work

Context

It break all my builds on appveyor, if I do not pin gitversion to 5.0.1

Your Environment

  • Version Used: 5.2.4
  • Operating System and version (Windows 10, Ubuntu 18.04): Windows
  • Link to your project: Private
  • Link to your CI build (if appropriate): Private

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions