From b5d7119ab49522c2b413455945b318f7b1d42bad Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 16 Jul 2024 22:56:25 +0000 Subject: [PATCH 1/9] fix(deps): update module github.com/adrg/xdg to v0.5.0 (#658) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [github.com/adrg/xdg](https://github.com/adrg/xdg) | require | minor | `v0.4.0` -> `v0.5.0` | --- ### Release Notes
adrg/xdg (github.com/adrg/xdg) ### [`v0.5.0`](https://github.com/adrg/xdg/releases/tag/v0.5.0) [Compare Source](https://github.com/adrg/xdg/compare/v0.4.0...v0.5.0) ##### Changelog - `user-dirs.dirs` config file is now parsed on Unix-like operating systems (except for macOS and Plan 9). See [XDG user directories](https://github.com/adrg/xdg?tab=readme-ov-file#xdg-user-directories) README section for more details. - Updated `golang.org/x/sys` dependency to the latest version. ##### Internal - Moved all path related functionality in internal `pathutil` package. - Added internal `userdirs` package: - Moved `xdg.UserDirectories` to `userdirs.Directories`. - Added parsing functions for `user-dirs.dirs` config file. - Improved package testing.
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://gitea.com/gitea/tea/pulls/658 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- go.mod | 4 ++-- go.sum | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index df4f657..9692eb0 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( code.gitea.io/sdk/gitea v0.18.0 gitea.com/noerw/unidiff-comments v0.0.0-20220822113322-50f4daa0e35c github.com/AlecAivazis/survey/v2 v2.3.7 - github.com/adrg/xdg v0.4.0 + github.com/adrg/xdg v0.5.0 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de github.com/charmbracelet/glamour v0.6.0 github.com/enescakir/emoji v1.0.0 @@ -65,7 +65,7 @@ require ( github.com/yuin/goldmark-emoji v1.0.1 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/net v0.22.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.15.0 // indirect golang.org/x/tools v0.13.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 671cd65..2569c23 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ github.com/acomagu/bufpipe v1.0.4 h1:e3H4WUzM3npvo5uv95QuJM3cQspFNtFBzvJ2oNjKIDQ github.com/acomagu/bufpipe v1.0.4/go.mod h1:mxdxdup/WdsKVreO5GpW4+M/1CE2sMG4jeGJ2sYmHc4= github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls= github.com/adrg/xdg v0.4.0/go.mod h1:N6ag73EX4wyxeaoeHctc1mas01KZgsj5tYiAIwqJE/E= +github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY= +github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -278,6 +280,8 @@ golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= From 16b37cc6dafed34810bc295ae67bbf9219c66449 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Tue, 16 Jul 2024 22:57:03 +0000 Subject: [PATCH 2/9] fix(deps): update module golang.org/x/term to v0.22.0 (#657) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | golang.org/x/term | require | minor | `v0.21.0` -> `v0.22.0` | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://gitea.com/gitea/tea/pulls/657 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 9692eb0..d7f67dc 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.25.7 golang.org/x/crypto v0.23.0 - golang.org/x/term v0.21.0 + golang.org/x/term v0.22.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 2569c23..3ca3bb4 100644 --- a/go.sum +++ b/go.sum @@ -308,6 +308,8 @@ golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.21.0 h1:WVXCp+/EBEHOj53Rvu+7KiT/iElMrO8ACK16SMZ3jaA= golang.org/x/term v0.21.0/go.mod h1:ooXLefLobQVslOqselCNF4SxFAaoS6KujMbsGzSDmX0= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= From 61bdc14184dd3ef0b3f87828450a11389c085f75 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 17 Jul 2024 01:39:18 +0000 Subject: [PATCH 3/9] fix(deps): update module golang.org/x/crypto to v0.25.0 (#652) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | golang.org/x/crypto | require | minor | `v0.23.0` -> `v0.25.0` | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://gitea.com/gitea/tea/pulls/652 Reviewed-by: 6543 <6543@obermui.de> Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- go.mod | 11 ++++++----- go.sum | 12 ++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index d7f67dc..fc0db07 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 github.com/stretchr/testify v1.9.0 github.com/urfave/cli/v2 v2.25.7 - golang.org/x/crypto v0.23.0 + golang.org/x/crypto v0.25.0 golang.org/x/term v0.22.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -63,10 +63,11 @@ require ( github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect github.com/yuin/goldmark v1.5.2 // indirect github.com/yuin/goldmark-emoji v1.0.1 // indirect - golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/mod v0.17.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.15.0 // indirect - golang.org/x/tools v0.13.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 3ca3bb4..bcfd753 100644 --- a/go.sum +++ b/go.sum @@ -210,11 +210,15 @@ golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= +golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -236,11 +240,15 @@ golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= +golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -324,6 +332,8 @@ golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200325010219-a49f79bcc224/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= @@ -331,6 +341,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 7e700e36f89fcbd6c91249c75e4ce01456e65112 Mon Sep 17 00:00:00 2001 From: techknowlogick Date: Thu, 18 Jul 2024 18:11:32 +0000 Subject: [PATCH 4/9] update template for issue reporting --- .gitea/issue_template/bug.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/issue_template/bug.md b/.gitea/issue_template/bug.md index 3057c94..b75142b 100644 --- a/.gitea/issue_template/bug.md +++ b/.gitea/issue_template/bug.md @@ -8,7 +8,7 @@ labels: ### describe your environment - tea version used (`tea -v`): - - [ ] I also reproduced the issue [with the latest master build](https://dl.gitea.com/tea/main/) + - [ ] I also reproduced the issue [with the latest main build](https://dl.gitea.com/tea/main/) - Gitea version used: - [ ] the issue only occurred after updating gitea recently - operating system: From 7cb6a84098b275d4fc03bb94ae856791f142a197 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 20 Jul 2024 13:37:20 +0000 Subject: [PATCH 5/9] chore(deps): update ghcr.io/devcontainers/features/git-lfs docker tag to v1.2.2 (#656) Reviewed-on: https://gitea.com/gitea/tea/pulls/656 Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index b5f5467..e50e261 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "name": "Tea DevContainer", "image": "mcr.microsoft.com/devcontainers/go:1.22-bullseye", "features": { - "ghcr.io/devcontainers/features/git-lfs:1.2.0": {} + "ghcr.io/devcontainers/features/git-lfs:1.2.2": {} }, "customizations": { "vscode": { From 18abf24dca8a5953f39146679907b741212a9c21 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 20 Jul 2024 13:37:49 +0000 Subject: [PATCH 6/9] chore(deps): update docker/build-push-action action to v6 (#655) Reviewed-on: https://gitea.com/gitea/tea/pulls/655 Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- .gitea/workflows/release-nightly.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/release-nightly.yml b/.gitea/workflows/release-nightly.yml index a6fbe21..d9828c0 100644 --- a/.gitea/workflows/release-nightly.yml +++ b/.gitea/workflows/release-nightly.yml @@ -61,7 +61,7 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Build and push - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 env: ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119 with: From 6d5e8d3b5867b2fd5c62823396bfc4cc4004caee Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sat, 20 Jul 2024 13:38:07 +0000 Subject: [PATCH 7/9] chore(deps): update goreleaser/goreleaser-action action to v6 (#654) Reviewed-on: https://gitea.com/gitea/tea/pulls/654 Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- .gitea/workflows/release-nightly.yml | 2 +- .gitea/workflows/release-tag.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/release-nightly.yml b/.gitea/workflows/release-nightly.yml index d9828c0..7cc076c 100644 --- a/.gitea/workflows/release-nightly.yml +++ b/.gitea/workflows/release-nightly.yml @@ -22,7 +22,7 @@ jobs: gpg_private_key: ${{ secrets.GPGSIGN_KEY }} passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }} - name: goreleaser - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser-pro version: latest diff --git a/.gitea/workflows/release-tag.yml b/.gitea/workflows/release-tag.yml index a236d3b..e3d0419 100644 --- a/.gitea/workflows/release-tag.yml +++ b/.gitea/workflows/release-tag.yml @@ -24,7 +24,7 @@ jobs: passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }} fingerprint: CC64B1DB67ABBEECAB24B6455FC346329753F4B0 - name: goreleaser - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser-pro version: latest From 22370698bf0e71a07a866c460ad8ecf972971cda Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Fri, 26 Jul 2024 16:01:37 +0000 Subject: [PATCH 8/9] fix(deps): update module github.com/charmbracelet/glamour to v0.7.0 (#631) Reviewed-on: https://gitea.com/gitea/tea/pulls/631 Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- go.mod | 9 +++++---- go.sum | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index fc0db07..db7118c 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/AlecAivazis/survey/v2 v2.3.7 github.com/adrg/xdg v0.5.0 github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de - github.com/charmbracelet/glamour v0.6.0 + github.com/charmbracelet/glamour v0.7.0 github.com/enescakir/emoji v1.0.0 github.com/go-git/go-git/v5 v5.12.0 github.com/muesli/termenv v0.15.2 @@ -28,6 +28,7 @@ require ( github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect github.com/alecthomas/chroma v0.10.0 // indirect + github.com/alecthomas/chroma/v2 v2.8.0 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect @@ -51,7 +52,7 @@ require ( github.com/mattn/go-isatty v0.0.18 // indirect github.com/mattn/go-runewidth v0.0.14 // indirect github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect - github.com/microcosm-cc/bluemonday v1.0.21 // indirect + github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/muesli/reflow v0.3.0 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -61,8 +62,8 @@ require ( github.com/skeema/knownhosts v1.2.2 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect - github.com/yuin/goldmark v1.5.2 // indirect - github.com/yuin/goldmark-emoji v1.0.1 // indirect + github.com/yuin/goldmark v1.5.4 // indirect + github.com/yuin/goldmark-emoji v1.0.2 // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.25.0 // indirect golang.org/x/sync v0.7.0 // indirect diff --git a/go.sum b/go.sum index bcfd753..c781650 100644 --- a/go.sum +++ b/go.sum @@ -31,6 +31,8 @@ github.com/adrg/xdg v0.5.0 h1:dDaZvhMXatArP1NPHhnfaQUqWBLBsmx1h1HXQdMoFCY= github.com/adrg/xdg v0.5.0/go.mod h1:dDdY4M4DF9Rjy4kHPeNL+ilVF+p2lK8IdM9/rTSGcI4= github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek= github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s= +github.com/alecthomas/chroma/v2 v2.8.0 h1:w9WJUjFFmHHB2e8mRpL9jjy3alYDlU0QLDezj1xE264= +github.com/alecthomas/chroma/v2 v2.8.0/go.mod h1:yrkMI9807G1ROx13fhe1v6PN2DDeaR73L3d+1nmYQtw= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de h1:FxWPpzIjnTlhPwqqXc4/vE0f7GvRjuAsbW+HOIe8KnA= github.com/araddon/dateparse v0.0.0-20210429162001-6b43995a97de/go.mod h1:DCaWoUhZrYW9p1lxo/cm8EmUOOzAPSEZNGF2DK1dJgw= @@ -43,6 +45,8 @@ github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd3 github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/charmbracelet/glamour v0.6.0 h1:wi8fse3Y7nfcabbbDuwolqTqMQPMnVPeZhDM273bISc= github.com/charmbracelet/glamour v0.6.0/go.mod h1:taqWV4swIMMbWALc0m7AfE9JkPSU8om2538k9ITBxOc= +github.com/charmbracelet/glamour v0.7.0 h1:2BtKGZ4iVJCDfMF229EzbeR1QRKLWztO9dMtjmqZSng= +github.com/charmbracelet/glamour v0.7.0/go.mod h1:jUMh5MeihljJPQbJ/wf4ldw2+yBP59+ctV36jASy7ps= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= @@ -124,6 +128,8 @@ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQ github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= github.com/microcosm-cc/bluemonday v1.0.21 h1:dNH3e4PSyE4vNX+KlRGHT5KrSvjeUkoNPwEORjffHJg= github.com/microcosm-cc/bluemonday v1.0.21/go.mod h1:ytNkv4RrDrLJ2pqlsSI46O6IVXmZOBBD4SaJyDwwTkM= +github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= +github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s= github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8= github.com/muesli/termenv v0.13.0/go.mod h1:sP1+uffeLaEYpyOTb8pLCUctGcGLnoFjSn4YJK5e2bc= @@ -178,11 +184,16 @@ github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRT github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.7/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.5.2 h1:ALmeCk/px5FSm1MAcFBAsVKZjDuMVj8Tm7FFIlMJnqU= github.com/yuin/goldmark v1.5.2/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU= +github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark-emoji v1.0.1 h1:ctuWEyzGBwiucEqxzwe0SOYDXPAucOrE9NQC18Wa1os= github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ= +github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s= +github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= From 20479663f09bcb9c5c31572cf34db6e755ea729e Mon Sep 17 00:00:00 2001 From: "leonard.vimond" Date: Fri, 26 Jul 2024 16:02:07 +0000 Subject: [PATCH 9/9] tea branches list/protect/unprotect (#645) Hello, This is a proposal to support consulting / protecting / unprotecting branches for a specific repository. I copied the existing code for "issues" report and adapted to branches. There is no change of legacy code so I do not expect any impact. Supported commands are "list", "protect", "unprotect": - "List" print the list of branches with some available fields from gitea.Branch type. - "protect" creates a gitea.BranchProtection with some default parameters for some specific branches - "unprotect" destroys gitea.BranchProtection for some specific branches What is printed now could be enriched with additional information gitea datatypes already offer. Could you please evaluate this proposal? I would be happy to receive any comment or remark to take into account. **tea branches unprotect** --login opsi --repo opensky main **tea branches list** --login opsi --repo opensky --fields name,protected,user-can-merge,user-can-push,protection [name protected user-can-merge user-can-push protection] +--------+-----------+----------------+---------------+------------+ | NAME | PROTECTED | USER-CAN-MERGE | USER-CAN-PUSH | PROTECTION | +--------+-----------+----------------+---------------+------------+ | b_test | false | true | true | | | main | false | true | true | | +--------+-----------+----------------+---------------+------------+ **tea branches protect** --login opsi --repo opensky main **tea branches list** --login opsi --repo opensky --fields name,protected,user-can-merge,user-can-push,protection [name protected user-can-merge user-can-push protection] +--------+-----------+----------------+---------------+----------------------+ | NAME | PROTECTED | USER-CAN-MERGE | USER-CAN-PUSH | PROTECTION | +--------+-----------+----------------+---------------+----------------------+ | b_test | false | true | true | | | main | true | true | false | - enable-push: false | | | | | | - approving: - | | | | | | merging: - pushing: | | | | | | | +--------+-----------+----------------+---------------+----------------------+ Following commands run OK: > make test > make fmt > make lint Co-authored-by: Leonard Vimond Co-authored-by: techknowlogick Reviewed-on: https://gitea.com/gitea/tea/pulls/645 Reviewed-by: techknowlogick Co-authored-by: leonard.vimond Co-committed-by: leonard.vimond --- cmd/branches.go | 36 ++++++++++++++ cmd/branches/list.go | 73 +++++++++++++++++++++++++++++ cmd/branches/protect.go | 101 ++++++++++++++++++++++++++++++++++++++++ docs/CLI.md | 82 ++++++++++++++++++++++++++++++++ main.go | 1 + modules/print/branch.go | 86 ++++++++++++++++++++++++++++++++++ 6 files changed, 379 insertions(+) create mode 100644 cmd/branches.go create mode 100644 cmd/branches/list.go create mode 100644 cmd/branches/protect.go create mode 100644 modules/print/branch.go diff --git a/cmd/branches.go b/cmd/branches.go new file mode 100644 index 0000000..31edee6 --- /dev/null +++ b/cmd/branches.go @@ -0,0 +1,36 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package cmd + +import ( + "code.gitea.io/tea/cmd/branches" + + "github.com/urfave/cli/v2" +) + +// CmdBranches represents to login a gitea server. +var CmdBranches = cli.Command{ + Name: "branches", + Aliases: []string{"branch", "b"}, + Category: catEntities, + Usage: "Consult branches", + Description: `Lists branches when called without argument. If a branch is provided, will show it in detail.`, + ArgsUsage: "[]", + Action: runBranches, + Subcommands: []*cli.Command{ + &branches.CmdBranchesList, + &branches.CmdBranchesProtect, + &branches.CmdBranchesUnprotect, + }, + Flags: append([]cli.Flag{ + &cli.BoolFlag{ + Name: "comments", + Usage: "Whether to display comments (will prompt if not provided & run interactively)", + }, + }, branches.CmdBranchesList.Flags...), +} + +func runBranches(ctx *cli.Context) error { + return branches.RunBranchesList(ctx) +} diff --git a/cmd/branches/list.go b/cmd/branches/list.go new file mode 100644 index 0000000..7d9cf46 --- /dev/null +++ b/cmd/branches/list.go @@ -0,0 +1,73 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package branches + +import ( + "code.gitea.io/tea/cmd/flags" + "code.gitea.io/tea/modules/context" + "code.gitea.io/tea/modules/print" + + "code.gitea.io/sdk/gitea" + "github.com/urfave/cli/v2" +) + +var branchFieldsFlag = flags.FieldsFlag(print.BranchFields, []string{ + "name", "protected", "user-can-merge", "user-can-push", +}) + +// CmdBranchesListFlags Flags for command list +var CmdBranchesListFlags = append([]cli.Flag{ + branchFieldsFlag, + &flags.PaginationPageFlag, + &flags.PaginationLimitFlag, +}, flags.AllDefaultFlags...) + +// CmdBranchesList represents a sub command of branches to list branches +var CmdBranchesList = cli.Command{ + Name: "list", + Aliases: []string{"ls"}, + Usage: "List branches of the repository", + Description: `List branches of the repository`, + ArgsUsage: " ", // command does not accept arguments + Action: RunBranchesList, + Flags: CmdBranchesListFlags, +} + +// RunBranchesList list branches +func RunBranchesList(cmd *cli.Context) error { + ctx := context.InitCommand(cmd) + ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) + + owner := ctx.Owner + if ctx.IsSet("owner") { + owner = ctx.String("owner") + } + + var branches []*gitea.Branch + var protections []*gitea.BranchProtection + var err error + branches, _, err = ctx.Login.Client().ListRepoBranches(owner, ctx.Repo, gitea.ListRepoBranchesOptions{ + ListOptions: ctx.GetListOptions(), + }) + + if err != nil { + return err + } + + protections, _, err = ctx.Login.Client().ListBranchProtections(owner, ctx.Repo, gitea.ListBranchProtectionsOptions{ + ListOptions: ctx.GetListOptions(), + }) + + if err != nil { + return err + } + + fields, err := branchFieldsFlag.GetValues(cmd) + if err != nil { + return err + } + + print.BranchesList(branches, protections, ctx.Output, fields) + return nil +} diff --git a/cmd/branches/protect.go b/cmd/branches/protect.go new file mode 100644 index 0000000..1883709 --- /dev/null +++ b/cmd/branches/protect.go @@ -0,0 +1,101 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package branches + +import ( + "fmt" + + "code.gitea.io/tea/cmd/flags" + "code.gitea.io/tea/modules/context" + + "code.gitea.io/sdk/gitea" + "github.com/urfave/cli/v2" +) + +// CmdBranchesProtectFlags Flags for command protect/unprotect +var CmdBranchesProtectFlags = append([]cli.Flag{ + branchFieldsFlag, + &flags.PaginationPageFlag, + &flags.PaginationLimitFlag, +}, flags.AllDefaultFlags...) + +// CmdBranchesProtect represents a sub command of branches to protect a branch +var CmdBranchesProtect = cli.Command{ + Name: "protect", + Aliases: []string{"P"}, + Usage: "Protect branches", + Description: `Block actions push/merge on specified branches`, + ArgsUsage: "", + Action: RunBranchesProtect, + Flags: CmdBranchesProtectFlags, +} + +// CmdBranchesUnprotect represents a sub command of branches to protect a branch +var CmdBranchesUnprotect = cli.Command{ + Name: "unprotect", + Aliases: []string{"U"}, + Usage: "Unprotect branches", + Description: `Suppress existing protections on specified branches`, + ArgsUsage: "", + Action: RunBranchesProtect, + Flags: CmdBranchesProtectFlags, +} + +// RunBranchesProtect function to protect/unprotect a list of branches +func RunBranchesProtect(cmd *cli.Context) error { + ctx := context.InitCommand(cmd) + ctx.Ensure(context.CtxRequirement{RemoteRepo: true}) + + if !cmd.Args().Present() { + return fmt.Errorf("must specify at least one branch") + } + + owner := ctx.Owner + if ctx.IsSet("owner") { + owner = ctx.String("owner") + } + + for _, branch := range ctx.Args().Slice() { + + var err error + command := ctx.Command.Name + if command == "protect" { + _, _, err = ctx.Login.Client().CreateBranchProtection(owner, ctx.Repo, gitea.CreateBranchProtectionOption{ + BranchName: branch, + RuleName: "", + EnablePush: false, + EnablePushWhitelist: false, + PushWhitelistUsernames: []string{}, + PushWhitelistTeams: []string{}, + PushWhitelistDeployKeys: false, + EnableMergeWhitelist: false, + MergeWhitelistUsernames: []string{}, + MergeWhitelistTeams: []string{}, + EnableStatusCheck: false, + StatusCheckContexts: []string{}, + RequiredApprovals: 1, + EnableApprovalsWhitelist: false, + ApprovalsWhitelistUsernames: []string{}, + ApprovalsWhitelistTeams: []string{}, + BlockOnRejectedReviews: false, + BlockOnOfficialReviewRequests: false, + BlockOnOutdatedBranch: false, + DismissStaleApprovals: false, + RequireSignedCommits: false, + ProtectedFilePatterns: "", + UnprotectedFilePatterns: "", + }) + } else if command == "unprotect" { + _, err = ctx.Login.Client().DeleteBranchProtection(owner, ctx.Repo, branch) + } else { + return fmt.Errorf("command %s is not supported", command) + } + + if err != nil { + return err + } + } + + return nil +} diff --git a/docs/CLI.md b/docs/CLI.md index aa3da52..81680c5 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -1119,6 +1119,88 @@ Migrate a repository **--wiki**: Copy the wiki +## branches, branch, b + +Consult branches + +**--comments**: Whether to display comments (will prompt if not provided & run interactively) + +**--fields, -f**="": Comma-separated list of fields to print. Available values: + name,protected,user-can-merge,user-can-push,protection + (default: name,protected,user-can-merge,user-can-push) + +**--limit, --lm**="": specify limit of items per page + +**--login, -l**="": Use a different Gitea Login. Optional + +**--output, -o**="": Output format. (simple, table, csv, tsv, yaml, json) + +**--page, -p**="": specify page, default is 1 + +**--remote, -R**="": Discover Gitea login from remote. Optional + +**--repo, -r**="": Override local repository path or gitea repository slug to interact with. Optional + +### list, ls + +List branches of the repository + +**--fields, -f**="": Comma-separated list of fields to print. Available values: + name,protected,user-can-merge,user-can-push,protection + (default: name,protected,user-can-merge,user-can-push) + +**--limit, --lm**="": specify limit of items per page + +**--login, -l**="": Use a different Gitea Login. Optional + +**--output, -o**="": Output format. (simple, table, csv, tsv, yaml, json) + +**--page, -p**="": specify page, default is 1 + +**--remote, -R**="": Discover Gitea login from remote. Optional + +**--repo, -r**="": Override local repository path or gitea repository slug to interact with. Optional + +### protect, P + +Protect branches + +**--fields, -f**="": Comma-separated list of fields to print. Available values: + name,protected,user-can-merge,user-can-push,protection + (default: name,protected,user-can-merge,user-can-push) + +**--limit, --lm**="": specify limit of items per page + +**--login, -l**="": Use a different Gitea Login. Optional + +**--output, -o**="": Output format. (simple, table, csv, tsv, yaml, json) + +**--page, -p**="": specify page, default is 1 + +**--remote, -R**="": Discover Gitea login from remote. Optional + +**--repo, -r**="": Override local repository path or gitea repository slug to interact with. Optional + +### unprotect, U + +Unprotect branches + +**--fields, -f**="": Comma-separated list of fields to print. Available values: + name,protected,user-can-merge,user-can-push,protection + (default: name,protected,user-can-merge,user-can-push) + +**--limit, --lm**="": specify limit of items per page + +**--login, -l**="": Use a different Gitea Login. Optional + +**--output, -o**="": Output format. (simple, table, csv, tsv, yaml, json) + +**--page, -p**="": specify page, default is 1 + +**--remote, -R**="": Discover Gitea login from remote. Optional + +**--repo, -r**="": Override local repository path or gitea repository slug to interact with. Optional + ## comment, c Add a comment to an issue / pr diff --git a/main.go b/main.go index 240452b..d5c3f1d 100644 --- a/main.go +++ b/main.go @@ -48,6 +48,7 @@ func main() { &cmd.CmdTrackedTimes, &cmd.CmdOrgs, &cmd.CmdRepos, + &cmd.CmdBranches, &cmd.CmdAddComment, &cmd.CmdOpen, diff --git a/modules/print/branch.go b/modules/print/branch.go new file mode 100644 index 0000000..1375a30 --- /dev/null +++ b/modules/print/branch.go @@ -0,0 +1,86 @@ +// Copyright 2024 The Gitea Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package print + +import ( + "fmt" + + "code.gitea.io/sdk/gitea" +) + +// BranchesList prints a listing of the branches +func BranchesList(branches []*gitea.Branch, protections []*gitea.BranchProtection, output string, fields []string) { + fmt.Println(fields) + printables := make([]printable, len(branches)) + + for i, branch := range branches { + var protection *gitea.BranchProtection + for _, p := range protections { + if p.BranchName == branch.Name { + protection = p + } + } + printables[i] = &printableBranch{branch, protection} + } + + t := tableFromItems(fields, printables, isMachineReadable(output)) + t.print(output) +} + +type printableBranch struct { + branch *gitea.Branch + protection *gitea.BranchProtection +} + +func (x printableBranch) FormatField(field string, machineReadable bool) string { + switch field { + case "name": + return x.branch.Name + case "protected": + return fmt.Sprintf("%t", x.branch.Protected) + case "user-can-merge": + return fmt.Sprintf("%t", x.branch.UserCanMerge) + case "user-can-push": + return fmt.Sprintf("%t", x.branch.UserCanPush) + case "protection": + if x.protection != nil { + approving := "" + for _, entry := range x.protection.ApprovalsWhitelistTeams { + approving += entry + "/" + } + for _, entry := range x.protection.ApprovalsWhitelistUsernames { + approving += entry + "/" + } + merging := "" + for _, entry := range x.protection.MergeWhitelistTeams { + approving += entry + "/" + } + for _, entry := range x.protection.MergeWhitelistUsernames { + approving += entry + "/" + } + pushing := "" + for _, entry := range x.protection.PushWhitelistTeams { + approving += entry + "/" + } + for _, entry := range x.protection.PushWhitelistUsernames { + approving += entry + "/" + } + return fmt.Sprintf( + "- enable-push: %t\n- approving: %s\n- merging: %s\n- pushing: %s\n", + x.protection.EnablePush, approving, merging, pushing, + ) + } + return "" + } + return "" +} + +// BranchFields are all available fields to print with BranchesList() +var BranchFields = []string{ + "name", + "protected", + "user-can-merge", + "user-can-push", + "protection", +}