summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-19 18:07:13 +0530
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-19 18:07:13 +0530
commit263a1509dbd79b1df3abe1bd42e2cd5d45448dea (patch)
treecfd115845d0f104fdb4794980a415c5f08ced8e0
parent194ec63d81ed7c8d6f63945139ea6d0bdfc597b3 (diff)
downloadlegit-263a1509dbd79b1df3abe1bd42e2cd5d45448dea.tar.gz
legit-263a1509dbd79b1df3abe1bd42e2cd5d45448dea.tar.bz2
legit-263a1509dbd79b1df3abe1bd42e2cd5d45448dea.zip
diff: show diff type
-rw-r--r--git/diff.go4
-rw-r--r--static/style.css4
-rw-r--r--templates/commit.html11
3 files changed, 18 insertions, 1 deletions
diff --git a/git/diff.go b/git/diff.go
index 063ac87..93c823a 100644
--- a/git/diff.go
+++ b/git/diff.go
@@ -21,6 +21,8 @@ type Diff struct {
}
TextFragments []TextFragment
IsBinary bool
+ IsNew bool
+ IsDelete bool
}
// A nicer git diff representation.
@@ -90,6 +92,8 @@ func (g *GitRepo) Diff() (*NiceDiff, error) {
ndiff.Name.New = d.NewName
ndiff.Name.Old = d.OldName
ndiff.IsBinary = d.IsBinary
+ ndiff.IsNew = d.IsNew
+ ndiff.IsDelete = d.IsDelete
for _, tf := range d.TextFragments {
ndiff.TextFragments = append(ndiff.TextFragments, TextFragment{
diff --git a/static/style.css b/static/style.css
index 1a59591..6d805a1 100644
--- a/static/style.css
+++ b/static/style.css
@@ -238,6 +238,10 @@ a:hover {
overflow: scroll;
}
+.diff-type {
+ color: var(--gray);
+}
+
.commit-info {
color: var(--gray);
padding-bottom: 1.5rem;
diff --git a/templates/commit.html b/templates/commit.html
index 65803b7..c37f850 100644
--- a/templates/commit.html
+++ b/templates/commit.html
@@ -46,8 +46,17 @@
{{ $repo := .name }}
{{ $this := .commit.This }}
{{ range .diff }}
- <div class="diff">
<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 }}
<a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
{{ if .Name.New }}