File: changeset_writer_tpl.go

package info (click to toggle)
golang-gitea-noerw-unidiff-comments 0.0~git20220822.50f4daa%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 336 kB
  • sloc: makefile: 4
file content (81 lines) | stat: -rw-r--r-- 1,356 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package writer

const commentsTplText = `
{{range $i, $_ := .}}

	{{"\n\n"}}

	{{if gt .Id 0}}
		[{{.Id}}@{{.Version}}] | {{.Author.DisplayName}} | {{.UpdatedDate}}
		{{"\n\n"}}
	{{end}}

	{{.Text | trimWhitespace}}

	{{"\n\n---"}}

	{{writeComments .Comments | indent}}
{{end}}`

const changesetTplText = `
{{range $i, $d := .Diffs}}
	{{if .Note}}
		{{writeNote .Note}}
		{{"\n"}}
	{{end}}

	{{if .FileComments}}
		{{"---" | comment}}
		{{"\n"}}
		{{writeComments .FileComments | comment}}
		{{"\n"}}
	{{end}}

	{{if .Hunks}}
		---{{" "}}
		{{if .Source.ToString}}
			{{.Source.ToString}}
		{{else}}
			/dev/null
		{{end}}
		{{"\t"}}
		{{$.FromHash}}
		{{"\n"}}

		+++{{" "}}
		{{if .Destination.ToString}}
			{{.Destination.ToString}}
		{{else}}
			/dev/null
		{{end}}
		{{"\t"}}
		{{$.ToHash}}
		{{"\n"}}

		{{range .Hunks}}
			@@ -{{.SourceLine}}{{if ne .SourceSpan 0}},{{.SourceSpan}}{{end}} +{{.DestinationLine}}{{if ne .DestinationSpan 0}},{{.DestinationSpan}}{{end}} @@
			{{"\n"}}

			{{range .Segments}}
				{{$segment := .}}
				{{range .Lines}}
					{{$segment.TextPrefix}}
					{{.Line}}

					{{"\n"}}
					{{if .Comments}}
						{{"---" | comment}}
						{{"\n"}}
						{{writeComments .Comments | comment}}
						{{"\n"}}
					{{end}}
				{{end}}

			{{end}}
		{{end}}
	{{end}}

	{{if not (last $i $.Diffs)}}
		{{"\n\n"}}
	{{end}}
{{end}}`