Skip to content

Commit

Permalink
Fix git open close bug (#12834)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Sep 14, 2020
1 parent 6a1a633 commit 642c3c2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions services/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"context"
"encoding/json"
"fmt"
"path"
"path/filepath"
"strings"
"time"

Expand Down Expand Up @@ -421,6 +421,7 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
if err != nil {
return fmt.Errorf("OpenRepository: %v", err)
}
defer gitRepo.Close()

if err := pr.LoadBaseRepo(); err != nil {
log.Error("Unable to load base repository for PR[%d] Error: %v", pr.ID, err)
Expand All @@ -429,12 +430,11 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
if err := gitRepo.AddRemote("base", pr.BaseRepo.RepoPath(), false); err != nil {
return fmt.Errorf("tmpGitRepo.AddRemote: %v", err)
}
defer gitRepo.Close()

headFile := pr.GetGitRefName()

// Remove head in case there is a conflict.
file := path.Join(pr.BaseRepo.RepoPath(), headFile)
file := filepath.Join(pr.BaseRepo.RepoPath(), headFile)

_ = util.Remove(file)

Expand Down

0 comments on commit 642c3c2

Please sign in to comment.