Skip to content

Commit

Permalink
remove unused git.IsErrUnsupportedVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
wxiaoguang committed Nov 2, 2024
1 parent 22f8b80 commit e93f255
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 26 deletions.
7 changes: 2 additions & 5 deletions routers/api/v1/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
unit_model "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
"code.gitea.io/gitea/modules/label"
"code.gitea.io/gitea/modules/log"
Expand Down Expand Up @@ -739,10 +738,8 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
if opts.DefaultBranch != nil && repo.DefaultBranch != *opts.DefaultBranch && (repo.IsEmpty || ctx.Repo.GitRepo.IsBranchExist(*opts.DefaultBranch)) {
if !repo.IsEmpty {
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, *opts.DefaultBranch); err != nil {
if !git.IsErrUnsupportedVersion(err) {
ctx.Error(http.StatusInternalServerError, "SetDefaultBranch", err)
return err
}
ctx.Error(http.StatusInternalServerError, "SetDefaultBranch", err)
return err
}
updateRepoLicense = true
}
Expand Down
11 changes: 4 additions & 7 deletions routers/private/default_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http"

repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
"code.gitea.io/gitea/modules/private"
gitea_context "code.gitea.io/gitea/services/context"
Expand All @@ -23,12 +22,10 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) {

ctx.Repo.Repository.DefaultBranch = branch
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil {
if !git.IsErrUnsupportedVersion(err) {
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: fmt.Sprintf("Unable to set default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
})
return
}
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: fmt.Sprintf("Unable to set default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
})
return
}

if err := repo_model.UpdateDefaultBranch(ctx, ctx.Repo.Repository); err != nil {
Expand Down
10 changes: 2 additions & 8 deletions services/mirror/mirror_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,8 @@ func checkAndUpdateEmptyRepository(ctx context.Context, m *repo_model.Mirror, re
}
// Update the git repository default branch
if err := gitrepo.SetDefaultBranch(ctx, m.Repo, m.Repo.DefaultBranch); err != nil {
if !git.IsErrUnsupportedVersion(err) {
log.Error("Failed to update default branch of underlying git repository %-v. Error: %v", m.Repo, err)
desc := fmt.Sprintf("Failed to update default branch of underlying git repository '%s': %v", m.Repo.RepoPath(), err)
if err = system_model.CreateRepositoryNotice(desc); err != nil {
log.Error("CreateRepositoryNotice: %v", err)
}
return false
}
log.Error("Failed to update default branch of underlying git repository %-v. Error: %v", m.Repo, err)
return false
}
m.Repo.IsEmpty = false
// Update the is empty and default_branch columns
Expand Down
4 changes: 1 addition & 3 deletions services/repository/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,7 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR
}

if err := gitrepo.SetDefaultBranch(ctx, repo, newBranchName); err != nil {

Check failure on line 605 in services/repository/branch.go

View workflow job for this annotation

GitHub Actions / lint-backend

if-return: redundant if ...; err != nil check, just return error instead. (revive)

Check failure on line 605 in services/repository/branch.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

if-return: redundant if ...; err != nil check, just return error instead. (revive)

Check failure on line 605 in services/repository/branch.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

if-return: redundant if ...; err != nil check, just return error instead. (revive)
if !git.IsErrUnsupportedVersion(err) {
return err
}
return err
}
return nil
}); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions services/repository/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
repo.IsEmpty = false
if repo.DefaultBranch != setting.Repository.DefaultBranch {
if err := gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch); err != nil {
if !git.IsErrUnsupportedVersion(err) {
return err
}
return err
}
}
// Update the is empty and default_branch columns
Expand Down

0 comments on commit e93f255

Please sign in to comment.