crystal-lang / shards

Dependency manager for the Crystal language
Other
763 stars 100 forks source link

make test fails with "command failed: git checkout master: -- error: pathspec 'master' did not match any file(s) known to git" #501

Closed szabgab closed 3 years ago

szabgab commented 3 years ago

I wanted to contribute a few test-cases so I cloned the shards repository ran make that was successful then I ran make test and got several exceptions:

crystal spec spec/unit/git_resolver_spec.cr:31 # Shards::GitResolver normalizes github bitbucket gitlab sources
crystal spec spec/unit/git_resolver_spec.cr:56 # Shards::GitResolver available releases
crystal spec spec/unit/git_resolver_spec.cr:61 # Shards::GitResolver latest version for ref
crystal spec spec/unit/git_resolver_spec.cr:78 # Shards::GitResolver versions for
crystal spec spec/unit/git_resolver_spec.cr:89 # Shards::GitResolver read spec for release
crystal spec spec/unit/git_resolver_spec.cr:95 # Shards::GitResolver read spec for commit
crystal spec spec/unit/git_resolver_spec.cr:102 # Shards::GitResolver install
crystal spec spec/unit/git_resolver_spec.cr:114 # Shards::GitResolver install commit
crystal spec spec/unit/git_resolver_spec.cr:121 # Shards::GitResolver origin changed
crystal spec spec/unit/git_resolver_spec.cr:165 # Shards::GitResolver renders report version
crystal spec spec/unit/git_resolver_spec.cr:170 # Shards::GitResolver #matches_ref

How can I ran the tests?

straight-shoota commented 3 years ago

You have to set git config init.defaultBranch to master.

szabgab commented 3 years ago

Doing that globally git config --global init.defaultBranch master fixes the problems, but that does not feel right. Why should one repository have an impact on my global git configuration.

Unfortunately doing it locally git config --local init.defaultBranch master did not help.

Why is this needed?

straight-shoota commented 3 years ago

It seems git changed the default branch name configuration. This breaks shards' specs because they expect it to be master.

A local change does not help because the spec suite creates new git repositories and they would inherit the default / global config.

szabgab commented 3 years ago

Git has changed and AFAIK now each one of us have to manually decided what is our default branch and we have to configure it. So I had "main" configured.

IMHO neither shard nor the tests should assume what is the globally configured default branch for the particular user.