Skip to content

Commit

Permalink
Set 'init.defaultBranch' in ci:setup to suppress 'git init' warning (#…
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
edmorley and schneems authored Jan 25, 2021
1 parent 051e5c9 commit 96dd837
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## HEAD

- Set `init.defaultBranch` in ci:setup to suppress `git init` warning in Git 2.30+ (https://github.com/heroku/hatchet/issues/172)
- Switch `heroku ci:install_heroku` to the Heroku CLI standalone installer rather than the APT install method (https://github.com/heroku/hatchet/issues/171)

## 7.3.3
Expand Down
2 changes: 2 additions & 0 deletions etc/ci_setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def run_cmd(command)
run_cmd "bundle exec hatchet install"
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'"
# Suppress the `git init` warning in Git 2.30+ when no default branch name is set.
run_cmd "git config --global init.defaultBranch main"

puts "== Done =="

0 comments on commit 96dd837

Please sign in to comment.