From 29fbdbc2096f4a004d62f2389a9f20ff9927c765 Mon Sep 17 00:00:00 2001 From: arrow2nd <44780846+arrow2nd@users.noreply.github.com> Date: Sun, 11 Dec 2022 12:14:30 +0900 Subject: [PATCH] v2.0.9 (#103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(app): viaが空文字の場合に表示が壊れる #102 * docs(CHANGELOG): v2.0.9 * chore(deps): 依存関係を更新 --- CHANGELOG.md | 9 ++++++++- app/layout_tweet.go | 6 +++++- app/layout_tweet_test.go | 19 +++++++++++++++++-- go.mod | 14 +++++++------- go.sum | 18 ++++++++++++++++-- 5 files changed, 53 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 205b476..5a2977b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## [Unreleased] +## [v2.0.9] - 2022-12-11 + +### Fixed + +- viaが空文字の場合に表示が壊れる + ## [v2.0.8] - 2022-10-28 ### Added @@ -159,7 +165,8 @@ - リリースしました! 😸 -[unreleased]: https://github.com/arrow2nd/nekome/compare/v2.0.8...HEAD +[unreleased]: https://github.com/arrow2nd/nekome/compare/v2.0.9...HEAD +[v2.0.9]: https://github.com/arrow2nd/nekome/compare/v2.0.8...v2.0.9 [v2.0.8]: https://github.com/arrow2nd/nekome/compare/v2.0.7...v2.0.8 [v2.0.7]: https://github.com/arrow2nd/nekome/compare/v2.0.6...v2.0.7 [v2.0.6]: https://github.com/arrow2nd/nekome/compare/v2.0.5...v2.0.6 diff --git a/app/layout_tweet.go b/app/layout_tweet.go index 2a53148..95c64a0 100644 --- a/app/layout_tweet.go +++ b/app/layout_tweet.go @@ -176,7 +176,11 @@ func createTweetDetailLayout(t *twitter.TweetObj) string { layout = replaceLayoutTag(layout, "{created_at}", date) // 投稿元クライアント - layout = replaceLayoutTag(layout, "{via}", t.Source) + via := t.Source + if via == "" { + via = "unknown" + } + layout = replaceLayoutTag(layout, "{via}", via) // メトリクス metrics := createTweetMetricsLayout(t) diff --git a/app/layout_tweet_test.go b/app/layout_tweet_test.go index a5aaac0..eb63c6a 100644 --- a/app/layout_tweet_test.go +++ b/app/layout_tweet_test.go @@ -360,11 +360,12 @@ func TestCreateTweetDetailLayout(t *testing.T) { }, } + p, _ := time.Parse(time.RFC3339, o.CreatedAt) + d := p.Local().Format("2006/01/02 15:04:05") + t.Run("作成できるか", func(t *testing.T) { s := createTweetDetailLayout(o) - p, _ := time.Parse(time.RFC3339, o.CreatedAt) - d := p.Local().Format("2006/01/02 15:04:05") want := fmt.Sprintf( `[style_detail]%s | via nekome for term [style_like]10likes[-:-:-] [style_rt]5rts[-:-:-][-:-:-]`, @@ -373,6 +374,20 @@ func TestCreateTweetDetailLayout(t *testing.T) { assert.Equal(t, want, s) }) + + t.Run("viaが空文字の場合にunknownが入るか", func(t *testing.T) { + o := *o + o.Source = "" + s := createTweetDetailLayout(&o) + + want := fmt.Sprintf( + `[style_detail]%s | via unknown +[style_like]10likes[-:-:-] [style_rt]5rts[-:-:-][-:-:-]`, + d, + ) + + assert.Equal(t, want, s) + }) } func TestCreateTweetMetricsLayout(t *testing.T) { diff --git a/go.mod b/go.mod index c942155..ea0d71a 100644 --- a/go.mod +++ b/go.mod @@ -6,13 +6,13 @@ require ( code.rocketnine.space/tslocum/cbind v0.1.5 github.com/BurntSushi/toml v1.2.1 github.com/atotto/clipboard v0.1.4 - github.com/dghubble/oauth1 v0.7.1 + github.com/dghubble/oauth1 v0.7.2 github.com/g8rswimmer/go-twitter/v2 v2.1.4 github.com/manifoldco/promptui v0.9.0 github.com/mattn/go-runewidth v0.0.14 github.com/skanehira/clipboard-image/v2 v2.0.0 github.com/spf13/pflag v1.0.5 - golang.org/x/term v0.2.0 + golang.org/x/term v0.3.0 ) require ( @@ -21,17 +21,17 @@ require ( github.com/gdamore/encoding v1.0.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/rivo/uniseg v0.4.2 // indirect - golang.org/x/text v0.4.0 // indirect + github.com/rivo/uniseg v0.4.3 // indirect + golang.org/x/text v0.5.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) require ( github.com/gdamore/tcell/v2 v2.5.3 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 - github.com/rivo/tview v0.0.0-20220916081518-2e69b7385a37 + github.com/rivo/tview v0.0.0-20221210235652-e6cd7110ac63 github.com/stretchr/testify v1.8.1 - golang.org/x/crypto v0.3.0 + golang.org/x/crypto v0.4.0 golang.org/x/sync v0.1.0 - golang.org/x/sys v0.2.0 // indirect + golang.org/x/sys v0.3.0 // indirect ) diff --git a/go.sum b/go.sum index 3b9ed24..41f5cb8 100644 --- a/go.sum +++ b/go.sum @@ -18,6 +18,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dghubble/oauth1 v0.7.1 h1:JjbOVSVVkms9A4h/sTQy5Jb2nFuAAVb2qVYgenJPyrE= github.com/dghubble/oauth1 v0.7.1/go.mod h1:0eEzON0UY/OLACQrmnjgJjmvCGXzjBCsZqL1kWDXtF0= +github.com/dghubble/oauth1 v0.7.2 h1:pwcinOZy8z6XkNxvPmUDY52M7RDPxt0Xw1zgZ6Cl5JA= +github.com/dghubble/oauth1 v0.7.2/go.mod h1:9erQdIhqhOHG/7K9s/tgh9Ks/AfoyrO5mW/43Lu2+kE= github.com/g8rswimmer/go-twitter/v2 v2.1.4 h1:BLnf4ZTIpRItlICbjIQGKnT9jcum9dQYHxJF7/hrJP0= github.com/g8rswimmer/go-twitter/v2 v2.1.4/go.mod h1:/55xWb313KQs25X7oZrNSEwLQNkYHhPsDwFstc45vhc= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= @@ -40,10 +42,14 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/tview v0.0.0-20220916081518-2e69b7385a37 h1:cTzFg1FfTXwXuODi7Doz70hsW+dAye1OBwAFWHCqmww= github.com/rivo/tview v0.0.0-20220916081518-2e69b7385a37/go.mod h1:YX2wUZOcJGOIycErz2s9KvDaP0jnWwRCirQMPLPpQ+Y= +github.com/rivo/tview v0.0.0-20221210235652-e6cd7110ac63 h1:4kfxHWea5BNbvgK2+branQdsSFld55Veww8wac8utK4= +github.com/rivo/tview v0.0.0-20221210235652-e6cd7110ac63/go.mod h1:YX2wUZOcJGOIycErz2s9KvDaP0jnWwRCirQMPLPpQ+Y= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.2 h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8= github.com/rivo/uniseg v0.4.2/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= +github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/skanehira/clipboard-image/v2 v2.0.0 h1:Kp+RNOgIlgzDkP3EskwuBnM0Fk4sc+HgcWE5RC+PnNI= github.com/skanehira/clipboard-image/v2 v2.0.0/go.mod h1:NXSYl4FJinIUFKJfeP1lGz8DIEUYjnEqwdMZ777S1E0= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -56,8 +62,10 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A= -golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE= +golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8= +golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -68,15 +76,21 @@ golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220318055525-2edf467146b5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ= +golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI= +golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM= +golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=