fork of go-gitdiff with jj support

Compare changes

Choose any two refs to compare.

+2 -2
.github/workflows/go.yml
··· 18 uses: actions/checkout@v4 19 20 - name: Lint 21 - uses: golangci/golangci-lint-action@v6 22 with: 23 - version: v1.59 24 25 - name: Test 26 run: go test -v ./...
··· 18 uses: actions/checkout@v4 19 20 - name: Lint 21 + uses: golangci/golangci-lint-action@v7 22 with: 23 + version: v2.0 24 25 - name: Test 26 run: go test -v ./...
+38 -37
.golangci.yml
··· 1 run: 2 tests: false 3 4 linters: 5 - disable-all: true 6 enable: 7 - errcheck 8 - - gofmt 9 - - goimports 10 - govet 11 - ineffassign 12 - misspell 13 - revive 14 - - typecheck 15 - unconvert 16 - unused 17 18 - issues: 19 - exclude-use-default: false 20 - 21 - linters-settings: 22 - errcheck: 23 - exclude-functions: 24 - - (*github.com/bluekeyes/go-gitdiff/gitdiff.formatter).Write 25 - - (*github.com/bluekeyes/go-gitdiff/gitdiff.formatter).WriteString 26 - - (*github.com/bluekeyes/go-gitdiff/gitdiff.formatter).WriteByte 27 - - fmt.Fprintf(*github.com/bluekeyes/go-gitdiff/gitdiff.formatter) 28 - goimports: 29 - local-prefixes: github.com/bluekeyes/go-gitdiff 30 - revive: 31 - rules: 32 - # enable all rules from golint 33 - - name: context-keys-type 34 - - name: time-naming 35 - - name: var-declaration 36 - - name: unexported-return 37 - - name: errorf 38 - - name: blank-imports 39 - - name: context-as-argument 40 - - name: dot-imports 41 - - name: error-return 42 - - name: error-strings 43 - - name: error-naming 44 - - name: exported 45 - - name: increment-decrement 46 - - name: var-naming 47 - - name: package-comments 48 - - name: range 49 - - name: receiver-naming 50 - - name: indent-error-flow
··· 1 + version: "2" 2 + 3 run: 4 tests: false 5 6 linters: 7 + default: none 8 enable: 9 - errcheck 10 - govet 11 - ineffassign 12 - misspell 13 - revive 14 - unconvert 15 - unused 16 + settings: 17 + errcheck: 18 + exclude-functions: 19 + - (*github.com/bluekeyes/go-gitdiff/gitdiff.formatter).Write 20 + - (*github.com/bluekeyes/go-gitdiff/gitdiff.formatter).WriteString 21 + - (*github.com/bluekeyes/go-gitdiff/gitdiff.formatter).WriteByte 22 + - fmt.Fprintf(*github.com/bluekeyes/go-gitdiff/gitdiff.formatter) 23 + revive: 24 + rules: 25 + - name: context-keys-type 26 + - name: time-naming 27 + - name: var-declaration 28 + - name: unexported-return 29 + - name: errorf 30 + - name: blank-imports 31 + - name: context-as-argument 32 + - name: dot-imports 33 + - name: error-return 34 + - name: error-strings 35 + - name: error-naming 36 + - name: exported 37 + - name: increment-decrement 38 + - name: var-naming 39 + - name: package-comments 40 + - name: range 41 + - name: receiver-naming 42 + - name: indent-error-flow 43 44 + formatters: 45 + enable: 46 + - gofmt 47 + - goimports 48 + settings: 49 + goimports: 50 + local-prefixes: 51 + - github.com/bluekeyes/go-gitdiff
+1 -1
README.md
··· 4 5 A Go library for parsing and applying patches generated by `git diff`, `git 6 show`, and `git format-patch`. It can also parse and apply unified diffs 7 - generated by the standard `diff` tool. 8 9 It supports standard line-oriented text patches and Git binary patches, and 10 aims to parse anything accepted by the `git apply` command.
··· 4 5 A Go library for parsing and applying patches generated by `git diff`, `git 6 show`, and `git format-patch`. It can also parse and apply unified diffs 7 + generated by the standard GNU `diff` tool. 8 9 It supports standard line-oriented text patches and Git binary patches, and 10 aims to parse anything accepted by the `git apply` command.
+1
gitdiff/apply_test.go
··· 22 "changeStart": {Files: getApplyFiles("text_fragment_change_start")}, 23 "changeMiddle": {Files: getApplyFiles("text_fragment_change_middle")}, 24 "changeEnd": {Files: getApplyFiles("text_fragment_change_end")}, 25 "changeExact": {Files: getApplyFiles("text_fragment_change_exact")}, 26 "changeSingleNoEOL": {Files: getApplyFiles("text_fragment_change_single_noeol")}, 27
··· 22 "changeStart": {Files: getApplyFiles("text_fragment_change_start")}, 23 "changeMiddle": {Files: getApplyFiles("text_fragment_change_middle")}, 24 "changeEnd": {Files: getApplyFiles("text_fragment_change_end")}, 25 + "changeEndEOL": {Files: getApplyFiles("text_fragment_change_end_eol")}, 26 "changeExact": {Files: getApplyFiles("text_fragment_change_exact")}, 27 "changeSingleNoEOL": {Files: getApplyFiles("text_fragment_change_single_noeol")}, 28
+13
gitdiff/patch_header.go
··· 52 // line, that line will be removed and everything after it will be 53 // placed in BodyAppendix. 54 BodyAppendix string 55 } 56 57 // Message returns the commit message for the header. The message consists of ··· 237 break 238 } 239 240 switch { 241 case strings.HasPrefix(line, authorPrefix): 242 u, err := ParsePatchIdentity(line[len(authorPrefix):]) ··· 361 } 362 363 h := &PatchHeader{} 364 365 if strings.HasPrefix(mailLine, mailHeaderPrefix) { 366 mailLine = strings.TrimPrefix(mailLine, mailHeaderPrefix)
··· 52 // line, that line will be removed and everything after it will be 53 // placed in BodyAppendix. 54 BodyAppendix string 55 + 56 + // All headers completely unparsed 57 + RawHeaders map[string][]string 58 } 59 60 // Message returns the commit message for the header. The message consists of ··· 240 break 241 } 242 243 + items := strings.SplitN(line, ":", 2) 244 + 245 + // we have "key: value" 246 + if len(items) == 2 { 247 + key := items[0] 248 + val := items[1] 249 + h.RawHeaders[key] = append(h.RawHeaders[key], val) 250 + } 251 + 252 switch { 253 case strings.HasPrefix(line, authorPrefix): 254 u, err := ParsePatchIdentity(line[len(authorPrefix):]) ··· 373 } 374 375 h := &PatchHeader{} 376 + h.RawHeaders = msg.Header 377 378 if strings.HasPrefix(mailLine, mailHeaderPrefix) { 379 mailLine = strings.TrimPrefix(mailLine, mailHeaderPrefix)
+3
gitdiff/testdata/apply/text_fragment_change_end_eol.out
···
··· 1 + line 1 2 + line 2 3 + line 3
+10
gitdiff/testdata/apply/text_fragment_change_end_eol.patch
···
··· 1 + diff --git a/gitdiff/testdata/apply/text_fragment_remove_last_eol.src b/gitdiff/testdata/apply/text_fragment_remove_last_eol.src 2 + index a92d664..8cf2f17 100644 3 + --- a/gitdiff/testdata/apply/text_fragment_remove_last_eol.src 4 + +++ b/gitdiff/testdata/apply/text_fragment_remove_last_eol.src 5 + @@ -1,3 +1,3 @@ 6 + line 1 7 + line 2 8 + -line 3 9 + +line 3 10 + \ No newline at end of file
+3
gitdiff/testdata/apply/text_fragment_change_end_eol.src
···
··· 1 + line 1 2 + line 2 3 + line 3