Migrate reviews when migrating repository from github (#9463)
* fix typo * Migrate reviews when migrating repository from github * fix lint * Added test and migration when external user login * fix test * fix commented state * Some improvements * fix bug when get pull request and ref original author on code comments * Fix migrated line; Added comment for review * Don't load all pull requests attributes * Fix typo * wrong change copy head * fix tests * fix reactions * Fix test * fix fmt * fix review comment reactions
This commit is contained in:
parent
bfdfa9a8b3
commit
f6067a8465
18 changed files with 567 additions and 32 deletions
|
@ -149,14 +149,9 @@ func (d *DiffLine) GetExpandDirection() DiffLineExpandDirection {
|
|||
return DiffLineExpandSingle
|
||||
}
|
||||
|
||||
func getDiffLineSectionInfo(curFile *DiffFile, line string, lastLeftIdx, lastRightIdx int) *DiffLineSectionInfo {
|
||||
var (
|
||||
leftLine int
|
||||
leftHunk int
|
||||
rightLine int
|
||||
righHunk int
|
||||
)
|
||||
ss := strings.Split(line, "@@")
|
||||
// ParseDiffHunkString parse the diffhunk content and return
|
||||
func ParseDiffHunkString(diffhunk string) (leftLine, leftHunk, rightLine, righHunk int) {
|
||||
ss := strings.Split(diffhunk, "@@")
|
||||
ranges := strings.Split(ss[1][1:], " ")
|
||||
leftRange := strings.Split(ranges[0], ",")
|
||||
leftLine, _ = com.StrTo(leftRange[0][1:]).Int()
|
||||
|
@ -170,12 +165,18 @@ func getDiffLineSectionInfo(curFile *DiffFile, line string, lastLeftIdx, lastRig
|
|||
righHunk, _ = com.StrTo(rightRange[1]).Int()
|
||||
}
|
||||
} else {
|
||||
log.Warn("Parse line number failed: %v", line)
|
||||
log.Warn("Parse line number failed: %v", diffhunk)
|
||||
rightLine = leftLine
|
||||
righHunk = leftHunk
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func getDiffLineSectionInfo(treePath, line string, lastLeftIdx, lastRightIdx int) *DiffLineSectionInfo {
|
||||
leftLine, leftHunk, rightLine, righHunk := ParseDiffHunkString(line)
|
||||
|
||||
return &DiffLineSectionInfo{
|
||||
Path: curFile.Name,
|
||||
Path: treePath,
|
||||
LastLeftIdx: lastLeftIdx,
|
||||
LastRightIdx: lastRightIdx,
|
||||
LeftIdx: leftLine,
|
||||
|
@ -651,7 +652,7 @@ func ParsePatch(maxLines, maxLineCharacters, maxFiles int, reader io.Reader) (*D
|
|||
case line[0] == '@':
|
||||
curSection = &DiffSection{}
|
||||
curFile.Sections = append(curFile.Sections, curSection)
|
||||
lineSectionInfo := getDiffLineSectionInfo(curFile, line, leftLine-1, rightLine-1)
|
||||
lineSectionInfo := getDiffLineSectionInfo(curFile.Name, line, leftLine-1, rightLine-1)
|
||||
diffLine := &DiffLine{
|
||||
Type: DiffLineSection,
|
||||
Content: line,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue