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

Suppress Git defaultBranch warnings #165

Closed
edmorley opened this issue Jan 8, 2021 · 0 comments · Fixed by #172
Closed

Suppress Git defaultBranch warnings #165

edmorley opened this issue Jan 8, 2021 · 0 comments · Fixed by #172
Assignees

Comments

@edmorley
Copy link
Member

edmorley commented Jan 8, 2021

Running Hatchet on Travis I see lots of warnings from Git about the upcoming defaultBranch change. eg:

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>

To resolve these we could add git config --global init.defaultBranch main here:

hatchet/etc/ci_setup.rb

Lines 31 to 33 in 97a18b8

run_cmd "git config --get user.email > /dev/null || git config --global user.email #{ENV.fetch('HEROKU_API_USER').shellescape}"
run_cmd "git config --get user.name > /dev/null || git config --global user.name 'BuildpackTester'"

@edmorley edmorley self-assigned this Jan 24, 2021
edmorley added a commit that referenced this issue Jan 25, 2021
In Git 2.30+, the `git init` command outputs a warning if
`init.defaultBranch` is not set in the Git configuration:
git/git@675704c

Setting this default in `ci:setup` ensures that the warning does not
spam CI logs every time `git init` is run.

This config change only affects new repos created by `git init`, not
repositories cloned using `git clone`. Hatchet uses `git init` when
the path passed to `App.new` is a local directory, and not a repository
cloned via `hatchet.lock`.

This changes the default branch for new repos from `master` to `main`,
however this works without further changes, since Hatchet already uses
`git push HEAD:main`, where `HEAD` will reference the current branch
regardless of its choice of name.

This change is also compatible with older versions of Git, since they
ignore unknown config file entries.

Fixes #165.
schneems added a commit that referenced this issue Jan 25, 2021
…172)

In Git 2.30+, the `git init` command outputs a warning if
`init.defaultBranch` is not set in the Git configuration:
git/git@675704c

Setting this default in `ci:setup` ensures that the warning does not
spam CI logs every time `git init` is run.

This config change only affects new repos created by `git init`, not
repositories cloned using `git clone`. Hatchet uses `git init` when
the path passed to `App.new` is a local directory, and not a repository
cloned via `hatchet.lock`.

This changes the default branch for new repos from `master` to `main`,
however this works without further changes, since Hatchet already uses
`git push HEAD:main`, where `HEAD` will reference the current branch
regardless of its choice of name.

This change is also compatible with older versions of Git, since they
ignore unknown config file entries.

Fixes #165.

Co-authored-by: Richard Schneeman <[email protected]>
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.

1 participant