diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-09-15 02:42:40 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-14 19:42:40 +0100 |
commit | 642c3c258bc0f4933c96dafeeed627d348498f0e (patch) | |
tree | c15b7ea9024c5f9a4fc0409492d1429352adc409 /services/pull | |
parent | 6a1a6332de5b5000d31ec26efaef6f78a4ee10f0 (diff) | |
download | gitea-642c3c258bc0f4933c96dafeeed627d348498f0e.tar.gz gitea-642c3c258bc0f4933c96dafeeed627d348498f0e.zip |
Fix git open close bug (#12834)
Diffstat (limited to 'services/pull')
-rw-r--r-- | services/pull/pull.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/services/pull/pull.go b/services/pull/pull.go index e624b182aa..790b747aa7 100644 --- a/services/pull/pull.go +++ b/services/pull/pull.go @@ -10,7 +10,7 @@ import ( "context" "encoding/json" "fmt" - "path" + "path/filepath" "strings" "time" @@ -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) @@ -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) |