diff: show diff type
This commit is contained in:
parent
194ec63d81
commit
263a1509db
|
@ -21,6 +21,8 @@ type Diff struct {
|
||||||
}
|
}
|
||||||
TextFragments []TextFragment
|
TextFragments []TextFragment
|
||||||
IsBinary bool
|
IsBinary bool
|
||||||
|
IsNew bool
|
||||||
|
IsDelete bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// A nicer git diff representation.
|
// A nicer git diff representation.
|
||||||
|
@ -90,6 +92,8 @@ func (g *GitRepo) Diff() (*NiceDiff, error) {
|
||||||
ndiff.Name.New = d.NewName
|
ndiff.Name.New = d.NewName
|
||||||
ndiff.Name.Old = d.OldName
|
ndiff.Name.Old = d.OldName
|
||||||
ndiff.IsBinary = d.IsBinary
|
ndiff.IsBinary = d.IsBinary
|
||||||
|
ndiff.IsNew = d.IsNew
|
||||||
|
ndiff.IsDelete = d.IsDelete
|
||||||
|
|
||||||
for _, tf := range d.TextFragments {
|
for _, tf := range d.TextFragments {
|
||||||
ndiff.TextFragments = append(ndiff.TextFragments, TextFragment{
|
ndiff.TextFragments = append(ndiff.TextFragments, TextFragment{
|
||||||
|
|
|
@ -238,6 +238,10 @@ a:hover {
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.diff-type {
|
||||||
|
color: var(--gray);
|
||||||
|
}
|
||||||
|
|
||||||
.commit-info {
|
.commit-info {
|
||||||
color: var(--gray);
|
color: var(--gray);
|
||||||
padding-bottom: 1.5rem;
|
padding-bottom: 1.5rem;
|
||||||
|
|
|
@ -46,8 +46,17 @@
|
||||||
{{ $repo := .name }}
|
{{ $repo := .name }}
|
||||||
{{ $this := .commit.This }}
|
{{ $this := .commit.This }}
|
||||||
{{ range .diff }}
|
{{ range .diff }}
|
||||||
<div class="diff">
|
|
||||||
<div id="{{ .Name.New }}">
|
<div id="{{ .Name.New }}">
|
||||||
|
<div class="diff">
|
||||||
|
{{ if .IsNew }}
|
||||||
|
<span class="diff-type">A</span>
|
||||||
|
{{ end }}
|
||||||
|
{{ if .IsDelete }}
|
||||||
|
<span class="diff-type">D</span>
|
||||||
|
{{ end }}
|
||||||
|
{{ if not (or .IsNew .IsDelete) }}
|
||||||
|
<span class="diff-type">M</span>
|
||||||
|
{{ end }}
|
||||||
{{ if .Name.Old }}
|
{{ if .Name.Old }}
|
||||||
<a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
|
<a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
|
||||||
{{ if .Name.New }}
|
{{ if .Name.New }}
|
||||||
|
|
Loading…
Reference in New Issue