Skip to content

Fix 500 error when creating blank repo with non-master default branch #18426

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/git/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func (repo *Repository) IsEmpty() (bool, error) {
var errbuf strings.Builder
if err := NewCommandContext(repo.Ctx, "log", "-1").RunInDirPipeline(repo.Path, nil, &errbuf); err != nil {
if strings.Contains(errbuf.String(), "fatal: bad default revision 'HEAD'") ||
strings.Contains(errbuf.String(), "fatal: your current branch 'master' does not have any commits yet") {
(strings.Contains(errbuf.String(), "fatal: your current branch '") &&
strings.Contains(errbuf.String(), "' does not have any commits yet")) {
return true, nil
}
return true, fmt.Errorf("check empty: %v - %s", err, errbuf.String())
Expand Down
2 changes: 1 addition & 1 deletion modules/git/tests/repos/repo2_empty/HEAD
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ref: refs/heads/master
ref: refs/heads/unicorn