Skip to content

Commit 4648584

Browse files
authored
On tag/branch-exist check, dont panic if repo is nil (#21787)
fix a panic found in gitea logs
1 parent 36cbaec commit 4648584

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

modules/git/repo_branch_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (repo *Repository) IsReferenceExist(name string) bool {
5252

5353
// IsBranchExist returns true if given branch exists in current repository.
5454
func (repo *Repository) IsBranchExist(name string) bool {
55-
if name == "" {
55+
if repo == nil || name == "" {
5656
return false
5757
}
5858

modules/git/repo_tag_nogogit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515

1616
// IsTagExist returns true if given tag exists in the repository.
1717
func (repo *Repository) IsTagExist(name string) bool {
18-
if name == "" {
18+
if repo == nil || name == "" {
1919
return false
2020
}
2121

0 commit comments

Comments
 (0)