diff options
40 files changed, 4353 insertions, 800 deletions
@@ -20,6 +20,7 @@ require ( github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 github.com/jesseduffield/gocui v0.3.1-0.20221003162644-fead10f7b360 github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 + github.com/jesseduffield/lazycore v0.0.0-20221009152330-3297d5700785 github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e github.com/jesseduffield/yaml v2.1.0+incompatible github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 @@ -29,15 +30,15 @@ require ( github.com/mgutz/str v1.2.0 github.com/pmezard/go-difflib v1.0.0 github.com/sahilm/fuzzy v0.1.0 - github.com/samber/lo v1.10.1 + github.com/samber/lo v1.31.0 github.com/sanity-io/litter v1.5.2 github.com/sasha-s/go-deadlock v0.3.1 github.com/sirupsen/logrus v1.4.2 github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.8.0 github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 gopkg.in/ozeidan/fuzzy-patricia.v3 v3.0.0 - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b + gopkg.in/yaml.v3 v3.0.1 ) require ( @@ -76,6 +76,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20221003162644-fead10f7b360 h1:43F6SAmNz github.com/jesseduffield/gocui v0.3.1-0.20221003162644-fead10f7b360/go.mod h1:znJuCDnF2Ph40YZSlBwdX/4GEofnIoWLGdT4mK5zRAU= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo= +github.com/jesseduffield/lazycore v0.0.0-20221009152330-3297d5700785 h1:o/XeosR2/jQgJPHjRuFABHFiXn51DsH35egR1h1ggo0= +github.com/jesseduffield/lazycore v0.0.0-20221009152330-3297d5700785/go.mod h1:m8oQ2wqlXm/sFuDGuKTaX2BNsRJ+nW76J7vetOoMr0o= github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e h1:uw/oo+kg7t/oeMs6sqlAwr85ND/9cpO3up3VxphxY0U= github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e/go.mod h1:u60qdFGXRd36jyEXxetz0vQceQIxzI13lIo3EFUDf4I= github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE= @@ -139,8 +141,8 @@ github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI= github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= -github.com/samber/lo v1.10.1 h1:0D3h7i0U3hRAbaCeQ82DLe67n0A7Bbl0/cEoWqFGp+U= -github.com/samber/lo v1.10.1/go.mod h1:2I7tgIv8Q1SG2xEIkRq0F2i2zgxVpnyPOP0d3Gj2r+A= +github.com/samber/lo v1.31.0 h1:Sfa+/064Tdo4SvlohQUQzBhgSer9v/coGvKQI/XLWAM= +github.com/samber/lo v1.31.0/go.mod h1:HLeWcJRRyLKp3+/XBJvOrerCQn9mhdKMHyd7IRlgeQ8= github.com/sanity-io/litter v1.5.2 h1:AnC8s9BMORWH5a4atZ4D6FPVvKGzHcnc5/IVTa87myw= github.com/sanity-io/litter v1.5.2/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0= github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= @@ -152,14 +154,17 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad h1:fiWzISvDn0Csy5H0iwgAuJGQTUpVfEMJJd4nRFXogbc= github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/thoas/go-funk v0.9.1 h1:O549iLZqPpTUQ10ykd26sZhzD+rmR5pWhuElrhbC20M= github.com/urfave/cli v1.20.1-0.20180226030253-8e01ec4cd3e2/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= @@ -223,5 +228,5 @@ gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/pkg/gui/arrangement.go b/pkg/gui/arrangement.go index 89236ae5c..ecff17893 100644 --- a/pkg/gui/arrangement.go +++ b/pkg/gui/arrangement.go @@ -1,7 +1,7 @@ package gui import ( - "github.com/jesseduffield/lazygit/pkg/gui/boxlayout" + "github.com/jesseduffield/lazycore/pkg/boxlayout" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/utils" diff --git a/pkg/gui/boxlayout/boxlayout_test.go b/pkg/gui/boxlayout/boxlayout_test.go deleted file mode 100644 index c2c0bc9e4..000000000 --- a/pkg/gui/boxlayout/boxlayout_test.go +++ /dev/null @@ -1,380 +0,0 @@ -package boxlayout - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestArrangeWindows(t *testing.T) { - type scenario struct { - testName string - root *Box - x0 int - y0 int - width int - height int - test func(result map[string]Dimensions) - } - - scenarios := []scenario{ - { - testName: "Empty box", - root: &Box{}, - x0: 0, - y0: 0, - width: 10, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues(t, result, map[string]Dimensions{}) - }, - }, - { - testName: "Box with static and dynamic panel", - root: &Box{Children: []*Box{{Size: 1, Window: "static"}, {Weight: 1, Window: "dynamic"}}}, - x0: 0, - y0: 0, - width: 10, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "dynamic": {X0: 0, X1: 9, Y0: 1, Y1: 9}, - "static": {X0: 0, X1: 9, Y0: 0, Y1: 0}, - }, - ) - }, - }, - { - testName: "Box with static and two dynamic panels", - root: &Box{Children: []*Box{{Size: 1, Window: "static"}, {Weight: 1, Window: "dynamic1"}, {Weight: 2, Window: "dynamic2"}}}, - x0: 0, - y0: 0, - width: 10, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "static": {X0: 0, X1: 9, Y0: 0, Y1: 0}, - "dynamic1": {X0: 0, X1: 9, Y0: 1, Y1: 3}, - "dynamic2": {X0: 0, X1: 9, Y0: 4, Y1: 9}, - }, - ) - }, - }, - { - testName: "Box with COLUMN direction", - root: &Box{Direction: COLUMN, Children: []*Box{{Size: 1, Window: "static"}, {Weight: 1, Window: "dynamic1"}, {Weight: 2, Window: "dynamic2"}}}, - x0: 0, - y0: 0, - width: 10, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "static": {X0: 0, X1: 0, Y0: 0, Y1: 9}, - "dynamic1": {X0: 1, X1: 3, Y0: 0, Y1: 9}, - "dynamic2": {X0: 4, X1: 9, Y0: 0, Y1: 9}, - }, - ) - }, - }, - { - testName: "Box with COLUMN direction only on wide boxes with narrow box", - root: &Box{ConditionalDirection: func(width int, height int) Direction { - if width > 4 { - return COLUMN - } else { - return ROW - } - }, Children: []*Box{{Weight: 1, Window: "dynamic1"}, {Weight: 1, Window: "dynamic2"}}}, - x0: 0, - y0: 0, - width: 4, - height: 4, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "dynamic1": {X0: 0, X1: 3, Y0: 0, Y1: 1}, - "dynamic2": {X0: 0, X1: 3, Y0: 2, Y1: 3}, - }, - ) - }, - }, - { - testName: "Box with COLUMN direction only on wide boxes with wide box", - root: &Box{ConditionalDirection: func(width int, height int) Direction { - if width > 4 { - return COLUMN - } else { - return ROW - } - }, Children: []*Box{{Weight: 1, Window: "dynamic1"}, {Weight: 1, Window: "dynamic2"}}}, - // 5 / 2 = 2 remainder 1. That remainder goes to the first box. - x0: 0, - y0: 0, - width: 5, - height: 5, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "dynamic1": {X0: 0, X1: 2, Y0: 0, Y1: 4}, - "dynamic2": {X0: 3, X1: 4, Y0: 0, Y1: 4}, - }, - ) - }, - }, - { - testName: "Box with conditional children where box is wide", - root: &Box{ConditionalChildren: func(width int, height int) []*Box { - if width > 4 { - return []*Box{{Window: "wide", Weight: 1}} - } else { - return []*Box{{Window: "narrow", Weight: 1}} - } - }}, - x0: 0, - y0: 0, - width: 5, - height: 5, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "wide": {X0: 0, X1: 4, Y0: 0, Y1: 4}, - }, - ) - }, - }, - { - testName: "Box with conditional children where box is narrow", - root: &Box{ConditionalChildren: func(width int, height int) []*Box { - if width > 4 { - return []*Box{{Window: "wide", Weight: 1}} - } else { - return []*Box{{Window: "narrow", Weight: 1}} - } - }}, - x0: 0, - y0: 0, - width: 4, - height: 4, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "narrow": {X0: 0, X1: 3, Y0: 0, Y1: 3}, - }, - ) - }, - }, - { - testName: "Box with static child with size too large", - root: &Box{Direction: COLUMN, Children: []*Box{{Size: 11, Window: "static"}, {Weight: 1, Window: "dynamic1"}, {Weight: 2, Window: "dynamic2"}}}, - x0: 0, - y0: 0, - width: 10, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "static": {X0: 0, X1: 9, Y0: 0, Y1: 9}, - // not sure if X0: 10, X1: 9 makes any sense, but testing this in the - // actual GUI it seems harmless - "dynamic1": {X0: 10, X1: 9, Y0: 0, Y1: 9}, - "dynamic2": {X0: 10, X1: 9, Y0: 0, Y1: 9}, - }, - ) - }, - }, - { - // 10 total space minus 2 from the status box leaves us with 8. - // Total weight is 3, 8 / 3 = 2 with 2 remainder. - // We want to end up with 2, 3, 5 (one unit from remainder to each dynamic box) - testName: "Distributing remainder across weighted boxes", - root: &Box{Direction: COLUMN, Children: []*Box{{Size: 2, Window: "static"}, {Weight: 1, Window: "dynamic1"}, {Weight: 2, Window: "dynamic2"}}}, - x0: 0, - y0: 0, - width: 10, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "static": {X0: 0, X1: 1, Y0: 0, Y1: 9}, // 2 - "dynamic1": {X0: 2, X1: 4, Y0: 0, Y1: 9}, // 3 - "dynamic2": {X0: 5, X1: 9, Y0: 0, Y1: 9}, // 5 - }, - ) - }, - }, - { - // 9 total space. - // total weight is 5, 9 / 5 = 1 with 4 remainder - // we want to give 2 of that remainder to the first, 1 to the second, and 1 to the last. - // Reason being that we just give units to each box evenly and consider weight in subsequent passes. - testName: "Distributing remainder across weighted boxes 2", - root: &Box{Direction: COLUMN, Children: []*Box{{Weight: 2, Window: "dynamic1"}, {Weight: 2, Window: "dynamic2"}, {Weight: 1, Window: "dynamic3"}}}, - x0: 0, - y0: 0, - width: 9, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "dynamic1": {X0: 0, X1: 3, Y0: 0, Y1: 9}, // 4 - "dynamic2": {X0: 4, X1: 6, Y0: 0, Y1: 9}, // 3 - "dynamic3": {X0: 7, X1: 8, Y0: 0, Y1: 9}, // 2 - }, - ) - }, - }, - { - // 9 total space. - // total weight is 5, 9 / 5 = 1 with 4 remainder - // we want to give 2 of that remainder to the first, 1 to the second, and 1 to the last. - // Reason being that we just give units to each box evenly and consider weight in subsequent passes. - testName: "Distributing remainder across weighted boxes with unnormalized weights", - root: &Box{Direction: COLUMN, Children: []*Box{{Weight: 4, Window: "dynamic1"}, {Weight: 4, Window: "dynamic2"}, {Weight: 2, Window: "dynamic3"}}}, - x0: 0, - y0: 0, - width: 9, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "dynamic1": {X0: 0, X1: 3, Y0: 0, Y1: 9}, // 4 - "dynamic2": {X0: 4, X1: 6, Y0: 0, Y1: 9}, // 3 - "dynamic3": {X0: 7, X1: 8, Y0: 0, Y1: 9}, // 2 - }, - ) - }, - }, - { - testName: "Another distribution test", - root: &Box{Direction: COLUMN, Children: []*Box{ - {Weight: 3, Window: "dynamic1"}, - {Weight: 1, Window: "dynamic2"}, - {Weight: 1, Window: "dynamic3"}, - }}, - x0: 0, - y0: 0, - width: 9, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "dynamic1": {X0: 0, X1: 4, Y0: 0, Y1: 9}, // 5 - "dynamic2": {X0: 5, X1: 6, Y0: 0, Y1: 9}, // 2 - "dynamic3": {X0: 7, X1: 8, Y0: 0, Y1: 9}, // 2 - }, - ) - }, - }, - { - testName: "Box with zero weight", - root: &Box{Direction: COLUMN, Children: []*Box{ - {Weight: 1, Window: "dynamic1"}, - {Weight: 0, Window: "dynamic2"}, - }}, - x0: 0, - y0: 0, - width: 10, - height: 10, - test: func(result map[string]Dimensions) { - assert.EqualValues( - t, - result, - map[string]Dimensions{ - "dynamic1": {X0: 0, X1: 9, Y0: 0, Y1: 9}, - "dynamic2": {X0: 10, X1: 9, Y0: 0, Y1: 9}, // when X0 > X1, we will hide the window - }, - ) - }, - }, - } - - for _, s := range scenarios { - s := s - t.Run(s.testName, func(t *testing.T) { - s.test(ArrangeWindows(s.root, s.x0, s.y0, s.width, s.height)) - }) - } -} - -func TestNormalizeWeights(t *testing.T) { - scenarios := []struct { - testName string - input []int - expected []int - }{ - { - testName: "empty", - input: []int{}, - expected: []int{}, - }, - { - testName: "one item of value 1", - input: []int{1}, - expected: []int{1}, - }, - { - testName: "one item of value greater than 1", - input: []int{2}, - expected: []int{1}, - }, - { - testName: "slice contains 1", - input: []int{2, 1}, - expected: []int{2, 1}, - }, - { - testName: "slice contains 2 and 2", - input: []int{2, 2}, - expected: []int{1, 1}, - }, - { - testName: "no common multiple", - input: []int{2, 3}, - expected: []int{2, 3}, - }, - { - testName: "complex case", - input: []int{10, 10, 20}, - expected: []int{1, 1, 2}, - }, - { - testName: "when a zero weight is included it is ignored", - input: []int{10, 10, 20, 0}, - expected: []int{1, 1, 2, 0}, - }, - } - - for _, s := range scenarios { - s := s - t.Run(s.testName, func(t *testing.T) { - assert.EqualValues(t, s.expected, normalizeWeights(s.input)) - }) - } -} diff --git a/vendor/github.com/jesseduffield/lazycore/LICENSE b/vendor/github.com/jesseduffield/lazycore/LICENSE new file mode 100644 index 000000000..2a7175dcc --- /dev/null +++ b/vendor/github.com/jesseduffield/lazycore/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Jesse Duffield + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/pkg/gui/boxlayout/boxlayout.go b/vendor/github.com/jesseduffield/lazycore/pkg/boxlayout/boxlayout.go index 4eb6f15e6..7cacfff98 100644 --- a/pkg/gui/boxlayout/boxlayout.go +++ b/vendor/github.com/jesseduffield/lazycore/pkg/boxlayout/boxlayout.go @@ -2,7 +2,7 @@ package boxlayout import ( "github.com/jesseduffield/generics/slices" - "github.com/jesseduffield/lazygit/pkg/utils" + "github.com/jesseduffield/lazycore/pkg/utils" "github.com/samber/lo" ) diff --git a/vendor/github.com/jesseduffield/lazycore/pkg/utils/utils.go b/vendor/github.com/jesseduffield/lazycore/pkg/utils/utils.go new file mode 100644 index 000000000..9fa933762 --- /dev/null +++ b/vendor/github.com/jesseduffield/lazycore/pkg/utils/utils.go @@ -0,0 +1,16 @@ +package utils + +// Min returns the minimum of two integers +func Min(x, y int) int { + if x < y { + return x + } + return y +} + +func Max(x, y int) int { + if x > y { + return x + } + return y +} diff --git a/vendor/github.com/samber/lo/.gitignore b/vendor/github.com/samber/lo/.gitignore index 3aa3a0ad4..e5ecc5c40 100644 --- a/vendor/github.com/samber/lo/.gitignore +++ b/vendor/github.com/samber/lo/.gitignore @@ -34,3 +34,5 @@ go.work cover.out cover.html .vscode + +.idea/ diff --git a/vendor/github.com/samber/lo/CHANGELOG.md b/vendor/github.com/samber/lo/CHANGELOG.md index aabeed120..9ba32f1b6 100644 --- a/vendor/github.com/samber/lo/CHANGELOG.md +++ b/vendor/github.com/samber/lo/CHANGELOG.md @@ -1,5 +1,281 @@ # Changelog +@samber: I sometimes forget to update this file. Ping me on [Twitter](https://twitter.com/samuelberthe) or open an issue in case of error. We need to keep a clear changelog for easier lib upgrade. + +## 1.31.0 (2022-10-06) + +Adding: + +- lo.SliceToChannel +- lo.Generator +- lo.Batch +- lo.BatchWithTimeout + +## 1.30.1 (2022-10-06) + +Fix: + +- lo.Try1: remove generic type +- lo.Validate: format error properly + +## 1.30.0 (2022-10-04) + +Adding: + +- lo.TernaryF +- lo.Validate + +## 1.29.0 (2022-10-02) + +Adding: + +- lo.ErrorAs +- lo.TryOr +- lo.TryOrX + +## 1.28.0 (2022-09-05) + +Adding: + +- lo.ChannelDispatcher with 6 dispatching strategies: + - lo.DispatchingStrategyRoundRobin + - lo.DispatchingStrategyRandom + - lo.DispatchingStrategyWeightedRandom + - lo.DispatchingStrategyFirst + - lo.DispatchingStrategyLeast + - lo.DispatchingStrategyMost + +## 1.27.1 (2022-08-15) + +Bugfix: + +- Removed comparable constraint for lo.FindKeyBy + +## 1.27.0 (2022-07-29) + +Breaking: + +- Change of MapToSlice prototype: `MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(V, K) R) []R` -> `MapToSlice[K comparable, V any, R any](in map[K]V, iteratee func(K, V) R) []R` + +Added: + +- lo.ChunkString +- lo.SliceToMap (alias to lo.Associate) + +## 1.26.0 (2022-07-24) + +Adding: + +- lo.Associate +- lo.ReduceRight +- lo.FromPtrOr +- lo.MapToSlice +- lo.IsSorted +- lo.IsSortedByKey + +## 1.25.0 (2022-07-04) + +Adding: + +- lo.FindUniques +- lo.FindUniquesBy +- lo.FindDuplicates +- lo.FindDuplicatesBy +- lo.IsNotEmpty + +## 1.24.0 (2022-07-04) + +Adding: + +- lo.Without +- lo.WithoutEmpty + +## 1.23.0 (2022-07-04) + +Adding: + +- lo.FindKey +- lo.FindKeyBy + +## 1.22.0 (2022-07-04) + +Adding: + +- lo.Slice +- lo.FromPtr +- lo.IsEmpty +- lo.Compact +- lo.ToPairs: alias to lo.Entries +- lo.FromPairs: alias to lo.FromEntries +- lo.Partial + +Change: + +- lo.Must + lo.MustX: add context to panic message + +Fix: + +- lo.Nth: out of bound |