cat / 012
clone

a spreadsheet for the terminal: lotus 1-2-3 looks, google sheets keys and formulas, one go binary

diff and merge compare tables one by one, as regions; monochrome table test moves beside the tables'

Dami committed 3ab9a99
commit
3ab9a995a14d9395c18b3321e4437d74d7c23f0b
parent
ea777836507b88d74b5a9f13b8c477cc50fe8bbf
author
Dami <dami.etoile@gmail.com>
kind
feat risk score 1.5 of 3, Jev's estimate
10 files changed, +88 -31
Mdocs/files/git.md3++-
Minternal/diff/cells.go5+++--
Minternal/diff/diff.go5++++-
Minternal/diff/diff_test.go18++++++++++++++++++
Minternal/diff/fields.go8+++++---
Minternal/diff/merge_test.go29+++++++++++++++++++++++++++++
Minternal/diff/mergesheets.go2++
Minternal/diff/text.go5+++--
Minternal/ui/monochrome_test.go22----------------------
Minternal/ui/tables_test.go22++++++++++++++++++++++
M docs/files/git.md +2 -1
M internal/diff/cells.go +3 -2
M internal/diff/diff.go +4 -1
M internal/diff/diff_test.go +18 -0
M internal/diff/fields.go +5 -3
M internal/diff/merge_test.go +29 -0
@@ -38,6 +38,35 @@ func input(w *sheet.Workbook, ref string) string {
3838 return c.Input3939 }4040 41+// Tables merge one by one: one side resizing a table and the other42+// adding one keeps both.43+func TestMergeTables(t *testing.T) {44+ cells := []map[string]string{{"A1": "Item", "B1": "Cost", "A2": "Rent", "B2": "5", "D1": "Tag", "D2": "x"}}45+ withTables := func(ts map[string]string) func(w *sheet.Workbook) {46+ return func(w *sheet.Workbook) {47+ for name, r := range ts {48+ rr, _ := sheet.ParseRange(r)49+ if err := w.Sheet(0).CreateTable(name, rr); err != nil {50+ t.Fatal(err)51+ }52+ }53+ }54+ }55+ base := file(t, []string{"S"}, cells, withTables(map[string]string{"Costs": "A1:B2"}))56+ ours := file(t, []string{"S"}, cells, withTables(map[string]string{"Costs": "A1:B3"}))57+ theirs := file(t, []string{"S"}, cells, withTables(map[string]string{"Costs": "A1:B2", "Tags": "D1:D2"}))58+ w, said := merge(t, base, ours, theirs)59+ if len(said) > 0 {60+ t.Errorf("conflicts %v", said)61+ }62+ s := w.Sheet(0)63+ costs, _ := s.TableAt(addr("A1"))64+ tags, _ := s.TableAt(addr("D1"))65+ if costs.Range.String() != "A1:B3" || tags.Name != "Tags" {66+ t.Errorf("tables %+v %+v", costs, tags)67+ }68+}69+4170 func TestMergeCells(t *testing.T) {4271 base := file(t, []string{"Sheet1"}, []map[string]string{{"A1": "Item", "B1": "1", "B2": "2", "B3": "3", "B4": "=SUM(B1:B3)"}}, nil)4372 ours := file(t, []string{"Sheet1"}, []map[string]string{{"A1": "Item", "B1": "10", "B2": "2", "B3": "30", "B4": "=SUM(B1:B3)", "C1": "ours"}}, nil)
M internal/diff/mergesheets.go +2 -0
M internal/diff/text.go +3 -2
M internal/ui/monochrome_test.go +0 -22
M internal/ui/tables_test.go +22 -0