Skip to content

Add more checks in migration code #21011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 4, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
oops
Signed-off-by: Andrew Thornton <[email protected]>
  • Loading branch information
zeripath committed Aug 31, 2022
commit 657d54dd5622d614f2f5fd91646f1668052d7a24
5 changes: 4 additions & 1 deletion services/migrations/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func (g *RepositoryDumper) handlePullRequest(pr *base.PullRequest) error {
for g.gitRepo.IsBranchExist(localRef) {
if i > 5 {
// ... We tried, we really tried but this is just a seriously unfriendly repo
continue
return fmt.Errorf("unable to create unique local reference from %s", pr.Head.Ref)
}
// OK just try some uuids!
localRef = git.SanitizeRefPattern("head-pr-" + strconv.FormatInt(pr.Number, 10) + uuid.New().String())
Expand All @@ -556,6 +556,9 @@ func (g *RepositoryDumper) handlePullRequest(pr *base.PullRequest) error {
g.prHeadCache[pr.Head.CloneURL+":"+pr.Head.Ref] = localRef
}

// Set the pr.Head.Ref to the localRef
pr.Head.Ref = localRef

// 5. Now if pr.Head.SHA == "" we should recover this to the head of this branch
if pr.Head.SHA == "" {
headSha, err := g.gitRepo.GetBranchCommitID(localRef)
Expand Down