Skip to content
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

Running tests fails if git's init.defaultbranch is not set to master #2007

Open
purp opened this issue Sep 24, 2023 · 5 comments · May be fixed by #2048
Open

Running tests fails if git's init.defaultbranch is not set to master #2007

purp opened this issue Sep 24, 2023 · 5 comments · May be fixed by #2048

Comments

@purp
Copy link
Contributor

purp commented Sep 24, 2023

Please read the CONTRIBUTION GUIDELINES before submitting!

Describe the bug
12 tests in test_page_view.rb fail with a Rugged::ReferenceError: reference 'refs/heads/master' not found error if you've set init.defaultbranch to anything other than master.

This seems to be because they're cloning test/examples/empty.git which has no branches in its refs/heads which causes clone to use init.defaultbranch to create the first branch in the cloned test directory, and the tests somehow require that branch to be named master. Workaround is, of course, pull that out of your config or change the value to master.

To Reproduce
Steps to reproduce the behavior:

> git config --global --add init.defaultbranch sticky-toffee-pudding
> bundle exec rake

... and see many errors.

Expected behavior
Didn't expect the default branch choice to break tests.

Environment Info

❯ bin/gollum --versions
Gollum 5.3.0
Running on: arm64-darwin22 with Ruby version 3.1.4
Using:
rugged 1.7.1
gollum-rugged_adapter 3.0
gollum-lib 6.0
Markdown rendering gem: kramdown
Other rendering gems:
none
@purp
Copy link
Contributor Author

purp commented Sep 24, 2023

Had a look at several possible ways to fix and have no idea what's the right one. Workaround's annoying but good enough for what I came to do.

@dometto
Copy link
Member

dometto commented Sep 25, 2023

Thanks for the report. This is actually an issue I ran into when trying to change the branch name for the gollum repository to main, it's helpful to have this issue as a reminder.

@benjaminwil
Copy link
Member

I've also run into this issue. To work around it, I set my local git config for the Gollum repo(s):

cd my-gollum-project
git config --local init.defaultbranch=master

But I think this isn't really a totally foolproof way of dealing with the issue. And I don't think it would be right to commit any git config to the repository.

That said, we could at least add that in the CONTRIBUTING instructions to the "Set up your development environment" section. What do you think?

@dometto
Copy link
Member

dometto commented Sep 26, 2023

That said, we could at least add that in the CONTRIBUTING instructions to the "Set up your development environment" section. What do you think?

That seems like a good temporary solution! Anyone have a moment to add this to CONTRIBUTING?

@benjaminwil
Copy link
Member

I’d be happy to do it in the next couple of days. I will also add a couple of sentences context about why this might be necessary in 2023.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants