diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-08-31 09:18:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-30 21:18:15 -0400 |
commit | 8d7704b5a2f7a0c7425a32bbc875fed15f515b4a (patch) | |
tree | 04dd5badfbe842e5d2c6b77720282ede5b828c8b /modules | |
parent | c0f5da3e1adfe40cafc57de63948ef1878bd75c9 (diff) | |
download | gitea-8d7704b5a2f7a0c7425a32bbc875fed15f515b4a.tar.gz gitea-8d7704b5a2f7a0c7425a32bbc875fed15f515b4a.zip |
Fix dump and restore respository (#16698)
* Fix dump and restore
* return different error message for get commit
* Fix missing delete release attachment when deleting repository
* Fix ci and add some comments
Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/migrations/dump.go | 9 | ||||
-rw-r--r-- | modules/migrations/gitea_uploader.go | 2 | ||||
-rw-r--r-- | modules/private/restore_repo.go | 1 |
3 files changed, 10 insertions, 2 deletions
diff --git a/modules/migrations/dump.go b/modules/migrations/dump.go index 6c4cf174d4..6b995c0dea 100644 --- a/modules/migrations/dump.go +++ b/modules/migrations/dump.go @@ -11,6 +11,7 @@ import ( "net/http" "net/url" "os" + "path" "path/filepath" "strconv" "strings" @@ -481,7 +482,9 @@ func (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error { if err != nil { log.Error("Fetch branch from %s failed: %v", pr.Head.CloneURL, err) } else { - headBranch := filepath.Join(g.gitPath(), "refs", "heads", pr.Head.OwnerName, pr.Head.Ref) + // a new branch name with <original_owner_name/original_branchname> will be created to as new head branch + ref := path.Join(pr.Head.OwnerName, pr.Head.Ref) + headBranch := filepath.Join(g.gitPath(), "refs", "heads", ref) if err := os.MkdirAll(filepath.Dir(headBranch), os.ModePerm); err != nil { return err } @@ -494,10 +497,14 @@ func (g *RepositoryDumper) CreatePullRequests(prs ...*base.PullRequest) error { if err != nil { return err } + pr.Head.Ref = ref } } } } + // whatever it's a forked repo PR, we have to change head info as the same as the base info + pr.Head.OwnerName = pr.Base.OwnerName + pr.Head.RepoName = pr.Base.RepoName } var err error diff --git a/modules/migrations/gitea_uploader.go b/modules/migrations/gitea_uploader.go index c77ace797b..c5eca35b2e 100644 --- a/modules/migrations/gitea_uploader.go +++ b/modules/migrations/gitea_uploader.go @@ -278,7 +278,7 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error { if !release.Draft { commit, err := g.gitRepo.GetTagCommit(rel.TagName) if err != nil { - return fmt.Errorf("GetCommit: %v", err) + return fmt.Errorf("GetTagCommit[%v]: %v", rel.TagName, err) } rel.NumCommits, err = commit.CommitsCount() if err != nil { diff --git a/modules/private/restore_repo.go b/modules/private/restore_repo.go index feb2e1d141..b5592278ab 100644 --- a/modules/private/restore_repo.go +++ b/modules/private/restore_repo.go @@ -54,6 +54,7 @@ func RestoreRepo(ctx context.Context, repoDir, ownerName, repoName string, units if err := json.Unmarshal(body, &ret); err != nil { return http.StatusInternalServerError, fmt.Sprintf("Response body Unmarshal error: %v", err.Error()) } + return http.StatusInternalServerError, ret.Err } return http.StatusOK, fmt.Sprintf("Restore repo %s/%s successfully", ownerName, repoName) |