History

format with gofumpt (#18184)

* gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt

6543 committed 4 years ago

Commit 54e9ee31 parent 1d98d20423 files · +1586 −1759Browse files

Showing the changes to services/gitdiff/gitdiff.go (1 of 423 files). Show all

Unified · Split

services/gitdiff/gitdiff.go+11−9
@@ -190,9 +190,11 @@ var ( · 189 unmodified lines
190 codeTagSuffix = []byte(`</span>`)190 codeTagSuffix = []byte(`</span>`)
191)191)
192 192
193var unfinishedtagRegex = regexp.MustCompile(`<[^>]*$`)193var (
194var trailingSpanRegex = regexp.MustCompile(`<span\s*[[:alpha:]="]*?[>]?$`)194 unfinishedtagRegex = regexp.MustCompile(`<[^>]*$`)
195var entityRegex = regexp.MustCompile(`&[#]*?[0-9[:alpha:]]*$`)195 trailingSpanRegex = regexp.MustCompile(`<span\s*[[:alpha:]="]*?[>]?$`)
196 entityRegex = regexp.MustCompile(`&[#]*?[0-9[:alpha:]]*$`)
197)
196 198
197// shouldWriteInline represents combinations where we manually write inline changes199// shouldWriteInline represents combinations where we manually write inline changes
198func shouldWriteInline(diff diffmatchpatch.Diff, lineType DiffLineType) bool {200func shouldWriteInline(diff diffmatchpatch.Diff, lineType DiffLineType) bool {
@@ -206,7 +208,6 @@ func shouldWriteInline(diff diffmatchpatch.Diff, lineType DiffLineType) bool { · 7 unmodified lines
206}208}
207 209
208func fixupBrokenSpans(diffs []diffmatchpatch.Diff) []diffmatchpatch.Diff {210func fixupBrokenSpans(diffs []diffmatchpatch.Diff) []diffmatchpatch.Diff {
209
210 // Create a new array to store our fixed up blocks211 // Create a new array to store our fixed up blocks
211 fixedup := make([]diffmatchpatch.Diff, 0, len(diffs))212 fixedup := make([]diffmatchpatch.Diff, 0, len(diffs))
212 213
@@ -658,10 +659,10 @@ func (diffFile *DiffFile) GetTailSection(gitRepo *git.Repository, leftCommitID, · 445 unmodified lines
658 LastRightIdx: lastLine.RightIdx,659 LastRightIdx: lastLine.RightIdx,
659 LeftIdx: leftLineCount,660 LeftIdx: leftLineCount,
660 RightIdx: rightLineCount,661 RightIdx: rightLineCount,
661 }}662 },
663 }
662 tailSection := &DiffSection{FileName: diffFile.Name, Lines: []*DiffLine{tailDiffLine}}664 tailSection := &DiffSection{FileName: diffFile.Name, Lines: []*DiffLine{tailDiffLine}}
663 return tailSection665 return tailSection
664
665}666}
666 667
667func getCommitFileLineCount(commit *git.Commit, filePath string) int {668func getCommitFileLineCount(commit *git.Commit, filePath string) int {
@@ -942,8 +943,8 @@ parsingLoop: · 274 unmodified lines
942 // TODO: There are numerous issues with this:943 // TODO: There are numerous issues with this:
943 // - we might want to consider detecting encoding while parsing but...944 // - we might want to consider detecting encoding while parsing but...
944 // - we're likely to fail to get the correct encoding here anyway as we won't have enough information945 // - we're likely to fail to get the correct encoding here anyway as we won't have enough information
945 var diffLineTypeBuffers = make(map[DiffLineType]*bytes.Buffer, 3)946 diffLineTypeBuffers := make(map[DiffLineType]*bytes.Buffer, 3)
946 var diffLineTypeDecoders = make(map[DiffLineType]*encoding.Decoder, 3)947 diffLineTypeDecoders := make(map[DiffLineType]*encoding.Decoder, 3)
947 diffLineTypeBuffers[DiffLinePlain] = new(bytes.Buffer)948 diffLineTypeBuffers[DiffLinePlain] = new(bytes.Buffer)
948 diffLineTypeBuffers[DiffLineAdd] = new(bytes.Buffer)949 diffLineTypeBuffers[DiffLineAdd] = new(bytes.Buffer)
949 diffLineTypeBuffers[DiffLineDel] = new(bytes.Buffer)950 diffLineTypeBuffers[DiffLineDel] = new(bytes.Buffer)
@@ -1539,7 +1540,8 @@ func GetWhitespaceFlag(whiteSpaceBehavior string) string { · 589 unmodified lines
1539 "ignore-all": "-w",1540 "ignore-all": "-w",
1540 "ignore-change": "-b",1541 "ignore-change": "-b",
1541 "ignore-eol": "--ignore-space-at-eol",1542 "ignore-eol": "--ignore-space-at-eol",
1542 "": ""}1543 "": "",
1544 }
1543 1545
1544 return whitespaceFlags[whiteSpaceBehavior]1546 return whitespaceFlags[whiteSpaceBehavior]
1545}1547}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t