Skip to content
Merged
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion modules/git/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ func InitRepository(repoPath string, bare bool) error {
func (repo *Repository) IsEmpty() (bool, error) {
var errbuf strings.Builder
if err := NewCommand("log", "-1").RunInDirPipeline(repo.Path, nil, &errbuf); err != nil {
defaultBranch, err := repo.GetDefaultBranch()
if err != nil {
return false, err
}
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(), fmt.Sprintf("fatal: your current branch '%s' does not have any commits yet", defaultBranch)) {
return true, nil
}
return true, fmt.Errorf("check empty: %v - %s", err, errbuf.String())
Expand Down