Skip to content

Commit 28e86b5

Browse files
committed
Fix dump and restore
1 parent 06b9d55 commit 28e86b5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

modules/migrations/dump.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net/http"
1212
"net/url"
1313
"os"
14+
"path"
1415
"path/filepath"
1516
"strconv"
1617
"strings"
@@ -481,6 +482,7 @@ func (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error {
481482
if err != nil {
482483
log.Error("Fetch branch from %s failed: %v", pr.Head.CloneURL, err)
483484
} else {
485+
ref := path.Join(pr.Head.OwnerName, pr.Head.Ref)
484486
headBranch := filepath.Join(g.gitPath(), "refs", "heads", pr.Head.OwnerName, pr.Head.Ref)
485487
if err := os.MkdirAll(filepath.Dir(headBranch), os.ModePerm); err != nil {
486488
return err
@@ -494,10 +496,14 @@ func (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error {
494496
if err != nil {
495497
return err
496498
}
499+
pr.Head.Ref = ref
497500
}
498501
}
499502
}
500503
}
504+
// store all information into local git repository
505+
pr.Head.OwnerName = pr.Base.OwnerName
506+
pr.Head.RepoName = pr.Base.RepoName
501507
}
502508

503509
var err error

modules/private/restore_repo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ func RestoreRepo(ctx context.Context, repoDir, ownerName, repoName string, units
5454
if err := json.Unmarshal(body, &ret); err != nil {
5555
return http.StatusInternalServerError, fmt.Sprintf("Response body Unmarshal error: %v", err.Error())
5656
}
57+
return http.StatusInternalServerError, ret.Err
5758
}
5859

5960
return http.StatusOK, fmt.Sprintf("Restore repo %s/%s successfully", ownerName, repoName)

0 commit comments

Comments
 (0)