Skip to content

Commit

Permalink
Fix possible race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
lafriks committed Oct 15, 2017
1 parent caccfb4 commit 3d0a597
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions models/repo_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ func (repo *Repository) CheckBranchName(name string) error {

// CreateNewBranch creates a new repository branch
func (repo *Repository) CreateNewBranch(doer *User, oldBranchName, branchName string) (err error) {
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))

// Check if branch name can be used
if err := repo.CheckBranchName(branchName); err != nil {
return err
}

repoWorkingPool.CheckIn(com.ToStr(repo.ID))
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))

localPath := repo.LocalCopyPath()

if err = discardLocalRepoBranchChanges(localPath, oldBranchName); err != nil {
Expand Down Expand Up @@ -157,14 +157,14 @@ func (repo *Repository) updateLocalCopyToCommit(commit string) error {

// CreateNewBranchFromCommit creates a new repository branch
func (repo *Repository) CreateNewBranchFromCommit(doer *User, commit, branchName string) (err error) {
repoWorkingPool.CheckIn(com.ToStr(repo.ID))
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))

// Check if branch name can be used
if err := repo.CheckBranchName(branchName); err != nil {
return err
}

repoWorkingPool.CheckIn(com.ToStr(repo.ID))
defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))

localPath := repo.LocalCopyPath()

if err = repo.updateLocalCopyToCommit(commit); err != nil {
Expand Down

0 comments on commit 3d0a597

Please sign in to comment.