Skip to content

Commit 00a42a8

Browse files
committed
remove unused git.IsErrUnsupportedVersion
1 parent 22f8b80 commit 00a42a8

File tree

5 files changed

+10
-29
lines changed

5 files changed

+10
-29
lines changed

routers/api/v1/repo/repo.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
repo_model "code.gitea.io/gitea/models/repo"
2222
unit_model "code.gitea.io/gitea/models/unit"
2323
user_model "code.gitea.io/gitea/models/user"
24-
"code.gitea.io/gitea/modules/git"
2524
"code.gitea.io/gitea/modules/gitrepo"
2625
"code.gitea.io/gitea/modules/label"
2726
"code.gitea.io/gitea/modules/log"
@@ -739,10 +738,8 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
739738
if opts.DefaultBranch != nil && repo.DefaultBranch != *opts.DefaultBranch && (repo.IsEmpty || ctx.Repo.GitRepo.IsBranchExist(*opts.DefaultBranch)) {
740739
if !repo.IsEmpty {
741740
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, *opts.DefaultBranch); err != nil {
742-
if !git.IsErrUnsupportedVersion(err) {
743-
ctx.Error(http.StatusInternalServerError, "SetDefaultBranch", err)
744-
return err
745-
}
741+
ctx.Error(http.StatusInternalServerError, "SetDefaultBranch", err)
742+
return err
746743
}
747744
updateRepoLicense = true
748745
}

routers/private/default_branch.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"net/http"
99

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

2423
ctx.Repo.Repository.DefaultBranch = branch
2524
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.Repository.DefaultBranch); err != nil {
26-
if !git.IsErrUnsupportedVersion(err) {
27-
ctx.JSON(http.StatusInternalServerError, private.Response{
28-
Err: fmt.Sprintf("Unable to set default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
29-
})
30-
return
31-
}
25+
ctx.JSON(http.StatusInternalServerError, private.Response{
26+
Err: fmt.Sprintf("Unable to set default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
27+
})
28+
return
3229
}
3330

3431
if err := repo_model.UpdateDefaultBranch(ctx, ctx.Repo.Repository); err != nil {

services/mirror/mirror_pull.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -613,14 +613,8 @@ func checkAndUpdateEmptyRepository(ctx context.Context, m *repo_model.Mirror, re
613613
}
614614
// Update the git repository default branch
615615
if err := gitrepo.SetDefaultBranch(ctx, m.Repo, m.Repo.DefaultBranch); err != nil {
616-
if !git.IsErrUnsupportedVersion(err) {
617-
log.Error("Failed to update default branch of underlying git repository %-v. Error: %v", m.Repo, err)
618-
desc := fmt.Sprintf("Failed to update default branch of underlying git repository '%s': %v", m.Repo.RepoPath(), err)
619-
if err = system_model.CreateRepositoryNotice(desc); err != nil {
620-
log.Error("CreateRepositoryNotice: %v", err)
621-
}
622-
return false
623-
}
616+
log.Error("Failed to update default branch of underlying git repository %-v. Error: %v", m.Repo, err)
617+
return false
624618
}
625619
m.Repo.IsEmpty = false
626620
// Update the is empty and default_branch columns

services/repository/branch.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,7 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR
602602
log.Error("CancelPreviousJobs: %v", err)
603603
}
604604

605-
if err := gitrepo.SetDefaultBranch(ctx, repo, newBranchName); err != nil {
606-
if !git.IsErrUnsupportedVersion(err) {
607-
return err
608-
}
609-
}
610-
return nil
605+
return gitrepo.SetDefaultBranch(ctx, repo, newBranchName)
611606
}); err != nil {
612607
return err
613608
}

services/repository/push.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ func pushUpdates(optsList []*repo_module.PushUpdateOptions) error {
183183
repo.IsEmpty = false
184184
if repo.DefaultBranch != setting.Repository.DefaultBranch {
185185
if err := gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch); err != nil {
186-
if !git.IsErrUnsupportedVersion(err) {
187-
return err
188-
}
186+
return err
189187
}
190188
}
191189
// Update the is empty and default_branch columns

0 commit comments

Comments
 (0)