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

Error when creating new repo: branch does not have any commits #18413

Closed
mmoomocow opened this issue Jan 26, 2022 · 1 comment · Fixed by #18422
Closed

Error when creating new repo: branch does not have any commits #18413

mmoomocow opened this issue Jan 26, 2022 · 1 comment · Fixed by #18422
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug
Milestone

Comments

@mmoomocow
Copy link

mmoomocow commented Jan 26, 2022

Gitea Version

1.16.0+rc1

Git Version

2.30.2

Operating System

Ubuntu server 20.04.3 LTS

How are you running Gitea?

Running on docker, config file:

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:latest
    container_name: gitea
    environment:
      - USER_UID=1004
      - USER_GID=1005
      - GITEA__SERVER__DOMAIN=git.example.com
      - GITEA__SERVER__ROOT_URL=https://git.example.com
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=password
      - GITEA__mailer__ENABLED=true
      - GITEA__mailer__FROM=noreply@example.com
      - GITEA__mailer__MAILER_TYPE=smtp
      - GITEA__mailer__HOST=smtp.example.com:465
      - GITEA__mailer__IS_TLS_ENABLED=true
      - GITEA__mailer__USER=noreply@example.com
      - GITEA__mailer__PASSWD=password
      - GITEA__service__DEFAULT_BRANCH=main
      - GITEA__security__DISABLE_GIT_HOOKS=false
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /home/git/.ssh/:/data/git/.ssh
    ports:
      - "8095:3000"
      - "127.0.0.1:2222:22"
    depends_on:
      - db

  db:
    image: postgres:13
    restart: always
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=password
      - POSTGRES_DB=gitea
    networks:
      - gitea
    volumes:
      - ./postgres:/var/lib/postgresql/data

Database

PostGres

Can you reproduce the bug on the Gitea demo site?

Yes

Log Gist

https://gist.github.com/mmoomocow/6eb9413b0d756551ebe8b225a890e730

Description

I created a repo, and set the default branch to main
Then when attempting to view the repo it shows error 500 and the error appears in the logs.
Repo on demo site mmoomocow/test

Screenshots

image

@wxiaoguang
Copy link
Contributor

It's caused by hard-coded error string:

			strings.Contains(errbuf.String(), "fatal: your current branch 'master' does not have any commits yet") {

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") {
return true, nil
}
return true, fmt.Errorf("check empty: %v - %s", err, errbuf.String())
}
return false, nil
}

@wxiaoguang wxiaoguang added type/bug issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented labels Jan 26, 2022
@wxiaoguang wxiaoguang added this to the 1.16.0 milestone Jan 26, 2022
@lunny lunny modified the milestones: 1.16.0, 1.15.11 Jan 28, 2022
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented type/bug
Projects
None yet
3 participants