Skip to content

Commit

Permalink
Stop printing pointless git default branch warning into logs/tests (#…
Browse files Browse the repository at this point in the history
…8632)

While running the `go_modules` tests, I noticed that the `git` warning
about an unspecified default branch was being repeatedly thrown in
tests.

Originally I assumed it was a bad test fixture setup, but I tracked it
down to here... so it may be filling production logs in addition to CI
logs.

Before adding this line:
```
[dependabot-core-dev] ~/go_modules $ rspec ./spec/dependabot/go_modules/file_updater_spec.rb

Randomized with seed 30583
...................hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
.hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
.hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
.hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
.hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
.

Finished in 21.32 seconds (files took 2.56 seconds to load)
24 examples, 0 failures

Randomized with seed 30583
```

After adding this:
```
[dependabot-core-dev] ~/go_modules $ rspec ./spec/dependabot/go_modules/file_updater_spec.rb

Randomized with seed 51472
........................

Finished in 22.24 seconds (files took 3.53 seconds to load)
24 examples, 0 failures

Randomized with seed 51472
```
  • Loading branch information
jeffwidman authored Dec 19, 2023
1 parent 4ec72a5 commit 961c875
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions go_modules/lib/dependabot/go_modules/file_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def use_repo_contents_stub
SharedHelpers.with_git_configured(credentials: []) do
`git config --global user.email "no-reply@github.com"`
`git config --global user.name "Dependabot"`
`git config --global init.defaultBranch "placeholder-default-branch"`
`git init .`
`git add .`
`git commit -m'fake repo_contents_path'`
Expand Down

0 comments on commit 961c875

Please sign in to comment.