Skip to content

When a repository is broken but git repository could be open, then mark it as normal #34443

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 1 commit 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
13 changes: 13 additions & 0 deletions models/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,19 @@ func (repo *Repository) MarkAsBrokenEmpty() {
repo.IsEmpty = true
}

func (repo *Repository) MarkAsNormal() {
repo.IsEmpty = false
repo.Status = RepositoryReady
}

func MarkBrokenRepoAsNormal(ctx context.Context, repo *Repository) error {
repo.MarkAsNormal()
if _, err := db.GetEngine(ctx).ID(repo.ID).Cols("status", "is_empty").Update(repo); err != nil {
return fmt.Errorf("update repository: %w", err)
}
return nil
}

// AfterLoad is invoked from XORM after setting the values of all fields of this object.
func (repo *Repository) AfterLoad() {
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
Expand Down
9 changes: 8 additions & 1 deletion services/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func RepoAssignment(ctx *Context) {
ctx.Link == ctx.Repo.RepoLink+"/-/migrate/status"

// Disable everything when the repo is being created
if ctx.Repo.Repository.IsBeingCreated() || ctx.Repo.Repository.IsBroken() {
if ctx.Repo.Repository.IsBeingCreated() {
if !isHomeOrSettings {
ctx.Redirect(ctx.Repo.RepoLink)
}
Expand Down Expand Up @@ -595,6 +595,13 @@ func RepoAssignment(ctx *Context) {
return
}

// The repository can be open but marked as broken
if ctx.Repo.Repository.IsBroken() {
if err = repo_model.MarkBrokenRepoAsNormal(ctx, ctx.Repo.Repository); err != nil {
log.Error("MarkBrokenRepoAsNormal: %v", err)
}
}

// Stop at this point when the repo is empty.
if ctx.Repo.Repository.IsEmpty {
return
Expand Down