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

Set 'init.defaultBranch' in ci:setup to suppress 'git init' warning #172

Merged
merged 2 commits into from
Jan 25, 2021

Conversation

edmorley
Copy link
Member

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.

@edmorley edmorley self-assigned this Jan 24, 2021
@edmorley
Copy link
Member Author

edmorley commented Jan 24, 2021

@schneems Hi :-) The Circle CI run is failing with "401 Unauthorized". Looking up the user it appears to have been deleted on 12th Jan (guessing due to it not having previously been identified as an internal user). Have started a discussion on Slack.

@edmorley
Copy link
Member Author

edmorley commented Jan 24, 2021

I've created a new CI user, which has fixed the HTTP 401 errors. However one spec is still failing, this time due to #173 - for which I've opened PR #174.

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.
@edmorley edmorley force-pushed the edmorley/git-init-default-branch branch from 290ffda to db88a3a Compare January 25, 2021 17:53
@schneems
Copy link
Contributor

Thanks!

@schneems schneems merged commit 96dd837 into main Jan 25, 2021
@schneems schneems deleted the edmorley/git-init-default-branch branch January 25, 2021 18:47
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 this pull request may close these issues.

Suppress Git defaultBranch warnings
2 participants