MCPcopy Create free account
hub / github.com/gogs/gogs / CreateNewBranch

Method CreateNewBranch

internal/database/repo.go:2633–2654  ·  view source on GitHub ↗

__________ .__ \______ \____________ ____ ____ | |__ | | _/\_ __ \__ \ / \_/ ___\| | \ | | \ | | \// __ \| | \ \___| Y \ |______ / |__| (____ /___| /\___ >___| / \/ \/ \/ \/ \/

(oldBranch, newBranch string)

Source from the content-addressed store, hash-verified

2631//
2632
2633func (r *Repository) CreateNewBranch(oldBranch, newBranch string) (err error) {
2634 repoWorkingPool.CheckIn(com.ToStr(r.ID))
2635 defer repoWorkingPool.CheckOut(com.ToStr(r.ID))
2636
2637 localPath := r.LocalCopyPath()
2638
2639 if err = discardLocalRepoBranchChanges(localPath, oldBranch); err != nil {
2640 return errors.Newf("discard changes in local copy [path: %s, branch: %s]: %v", localPath, oldBranch, err)
2641 } else if err = r.UpdateLocalCopyBranch(oldBranch); err != nil {
2642 return errors.Newf("update branch for local copy [path: %s, branch: %s]: %v", localPath, oldBranch, err)
2643 }
2644
2645 if err = r.CheckoutNewBranch(oldBranch, newBranch); err != nil {
2646 return errors.Newf("create new branch [base: %s, new: %s]: %v", oldBranch, newBranch, err)
2647 }
2648
2649 if err = git.Push(localPath, "origin", newBranch); err != nil {
2650 return errors.Newf("push [branch: %s]: %v", newBranch, err)
2651 }
2652
2653 return nil
2654}
2655
2656// Deprecated: Use Perms.SetRepoPerms instead.
2657func (r *Repository) refreshAccesses(e Engine, accessMap map[int64]AccessMode) (err error) {

Callers

nothing calls this directly

Implementers 2

Repositoryinternal/database/repo.go
mailerRepointernal/database/issue_mail.go

Calls 6

LocalCopyPathMethod · 0.95
UpdateLocalCopyBranchMethod · 0.95
CheckoutNewBranchMethod · 0.95
CheckInMethod · 0.80
CheckOutMethod · 0.80

Tested by

no test coverage detected