Skip to content

Commit c54bc3f

Browse files
committed
use GetCommit matching all tag/branch/commit sha
1 parent 844db28 commit c54bc3f

File tree

1 file changed

+3
-20
lines changed

1 file changed

+3
-20
lines changed

routers/api/v1/repo/branch.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -177,26 +177,9 @@ func CreateBranch(ctx *context.APIContext) {
177177
var err error
178178

179179
if len(opt.OldRefName) > 0 {
180-
if ctx.Repo.GitRepo.IsBranchExist(opt.OldRefName) {
181-
oldCommit, err = ctx.Repo.GitRepo.GetBranchCommit(opt.OldRefName)
182-
if err != nil {
183-
ctx.Error(http.StatusInternalServerError, "GetBranchCommit", err)
184-
return
185-
}
186-
} else if ctx.Repo.GitRepo.IsTagExist(opt.OldRefName) {
187-
oldCommit, err = ctx.Repo.GitRepo.GetTagCommit(opt.OldRefName)
188-
if err != nil {
189-
ctx.Error(http.StatusInternalServerError, "GetTagCommit", err)
190-
return
191-
}
192-
} else if len(opt.OldRefName) == git.SHAFullLength {
193-
oldCommit, err = ctx.Repo.GitRepo.GetCommit(opt.OldRefName)
194-
if err != nil {
195-
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
196-
return
197-
}
198-
} else {
199-
ctx.Error(http.StatusNotFound, "", "OldRefName is not exits.")
180+
oldCommit, err = ctx.Repo.GitRepo.GetCommit(opt.OldRefName)
181+
if err != nil {
182+
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
200183
return
201184
}
202185
} else if len(opt.OldBranchName) > 0 {

0 commit comments

Comments
 (0)