Fix git open close bug (#12834)
This commit is contained in:
parent
6a1a6332de
commit
642c3c258b
1 changed files with 3 additions and 3 deletions
|
@ -10,7 +10,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -421,6 +421,7 @@ func PushToBaseRepo(pr *models.PullRequest) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("OpenRepository: %v", err)
|
return fmt.Errorf("OpenRepository: %v", err)
|
||||||
}
|
}
|
||||||
|
defer gitRepo.Close()
|
||||||
|
|
||||||
if err := pr.LoadBaseRepo(); err != nil {
|
if err := pr.LoadBaseRepo(); err != nil {
|
||||||
log.Error("Unable to load base repository for PR[%d] Error: %v", pr.ID, err)
|
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 {
|
if err := gitRepo.AddRemote("base", pr.BaseRepo.RepoPath(), false); err != nil {
|
||||||
return fmt.Errorf("tmpGitRepo.AddRemote: %v", err)
|
return fmt.Errorf("tmpGitRepo.AddRemote: %v", err)
|
||||||
}
|
}
|
||||||
defer gitRepo.Close()
|
|
||||||
|
|
||||||
headFile := pr.GetGitRefName()
|
headFile := pr.GetGitRefName()
|
||||||
|
|
||||||
// Remove head in case there is a conflict.
|
// 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)
|
_ = util.Remove(file)
|
||||||
|
|
||||||
|
|
Reference in a new issue