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

Clean up/refactor git configuration #7538

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions .crew-gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# This file is not the .gitconfig file created by the user
# This file is for internal use by chromebrew when calling git

# It sets sane defaults when cloning repositories for building use
# and is designed to minimize unnecessary advice and hints from git
# meant for the end user

[advice]
# remove detached HEAD warning
detachedHead = false

[init]
# avoid initial branch name warning
defaultBranch = main
5 changes: 2 additions & 3 deletions bin/crew
Original file line number Diff line number Diff line change
Expand Up @@ -772,9 +772,8 @@ def download
Dir.mkdir @extract_dir
Dir.chdir @extract_dir do
if @pkg.git_branch.to_s.empty?
system 'git init'
system 'git config advice.detachedHead false'
system 'git config init.defaultBranch master'
system 'git init --quiet', exception: true # use --quiet to suppress default branch name warning
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of quiet. Hiding stuff is not what I prefer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no other way to hide this:

Performing pre-flight checks...
No precompiled binary available for your platform, downloading source...
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>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried git config --global init.defaultBranch master? That should make the message go away.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably start setting git config --global init.defaultBranch main since that's becoming the new norm...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get rid of line 775 and merge this?
The git config line in line 776 should in theory make this message go away, no?

system "git config include.path #{CREW_LIB_PATH}/.crew-gitconfig" # use our .gitconfig file too
system "git remote add origin #{@pkg.source_url}", exception: true
system "git fetch --depth 1 origin #{@pkg.git_hashtag}", exception: true
system 'git checkout FETCH_HEAD'
Expand Down