Compare commits

...

219 Commits
v0.6.0 ... main

Author SHA1 Message Date
Matheus Sampaio Queiroga
2984ad4964 Add git helper (#612)
Add support to tea login with helper same another tools and `gh`

Reviewed-on: https://gitea.com/gitea/tea/pulls/612
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
Co-committed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2024-08-26 11:34:36 +00:00
Renovate Bot
a35bf931ae fix(deps): update module golang.org/x/crypto to v0.26.0 (#664)
Reviewed-on: https://gitea.com/gitea/tea/pulls/664
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-08-16 18:59:57 +00:00
Renovate Bot
edf9f23390 chore(deps): update dependency go to v1.23.0 (#668)
Reviewed-on: https://gitea.com/gitea/tea/pulls/668
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-08-16 18:59:44 +00:00
Renovate Bot
0297738b33 fix(deps): update module code.gitea.io/sdk/gitea to v0.19.0 (#662)
Reviewed-on: https://gitea.com/gitea/tea/pulls/662
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-08-16 16:06:56 +00:00
Renovate Bot
1983c3bbd9 fix(deps): update module github.com/charmbracelet/glamour to v0.8.0 (#663)
Reviewed-on: https://gitea.com/gitea/tea/pulls/663
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-08-16 16:06:30 +00:00
Renovate Bot
d289c290bb fix(deps): update module golang.org/x/term to v0.23.0 (#665)
Reviewed-on: https://gitea.com/gitea/tea/pulls/665
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-08-16 16:06:05 +00:00
harryzcy
100c5a9eee Support auto detecting branch for PRs (#525)
Fix #524

Co-authored-by: harryzcy <harry@harryzheng.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/525
Co-authored-by: harryzcy <harryzcy@noreply.gitea.com>
Co-committed-by: harryzcy <harryzcy@noreply.gitea.com>
2024-07-26 19:21:48 +00:00
Renovate Bot
4ba3139224 fix(deps): update module github.com/urfave/cli/v2 to v2.27.3 (#610)
Reviewed-on: https://gitea.com/gitea/tea/pulls/610
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-26 18:06:26 +00:00
Renovate Bot
dd80463cf5 chore(deps): update actions/checkout action to v4 (#661)
Reviewed-on: https://gitea.com/gitea/tea/pulls/661
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-26 18:00:52 +00:00
techknowlogick
93480ac98e use v1 of goreleaser until we can bump schema to v2 2024-07-26 16:25:37 +00:00
techknowlogick
f7e2c6f89b v1 of goreleaser until we can update to schema 2 2024-07-26 16:24:42 +00:00
Jake Hillion
493b29afbf context: move human readable note to stderr (#636)
The NOTE shown when an explicit login isn't provided is output on Stdout
instead of Stderr. This messes up the output of any commands when piping
them to a tool such as `yq`. Move this human readable information to
Stderr so it doesn't break any automated parsing.

Reviewed-on: https://gitea.com/gitea/tea/pulls/636
Co-authored-by: Jake Hillion <jake@hillion.co.uk>
Co-committed-by: Jake Hillion <jake@hillion.co.uk>
2024-07-26 16:21:07 +00:00
Dan Čermák
723b0553c5 Add repos rm/delete command (#609)
This fixes https://gitea.com/gitea/tea/issues/239

Co-authored-by: techknowlogick <techknowlogick@gitea.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/609
Co-authored-by: Dan Čermák <dcermak@suse.com>
Co-committed-by: Dan Čermák <dcermak@suse.com>
2024-07-26 16:18:58 +00:00
danebou
4c0cef090d Release Asset Management (#619)
Add release asset management. This includes a series of subcommands under `tea release assets`:

-  `tea release assets create <release-tag> <asset> [<asset>...]`: Upload one or more release attachments
- `tea release assets delete <release tag> <attachment name> [<attachment name>...]`: Delete one or more release attachments
- `tea release assets list <release tag>`: List Release Attachments

Co-authored-by: Dane Bouchie <dbouchie@iradimed.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/619
Co-authored-by: danebou <danebou@noreply.gitea.com>
Co-committed-by: danebou <danebou@noreply.gitea.com>
2024-07-26 16:05:12 +00:00
leonard.vimond
20479663f0 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          | <None>     |
| main   | false     | true           | true          | <None>     |
+--------+-----------+----------------+---------------+------------+

**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          | <None>               |
| 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 <leonard.vimond.e@thalesdigital.io>
Co-authored-by: techknowlogick <techknowlogick@noreply.gitea.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/645
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: leonard.vimond <leonard.vimond@noreply.gitea.com>
Co-committed-by: leonard.vimond <leonard.vimond@noreply.gitea.com>
2024-07-26 16:02:07 +00:00
Renovate Bot
22370698bf 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 <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-26 16:01:37 +00:00
Renovate Bot
6d5e8d3b58 chore(deps): update goreleaser/goreleaser-action action to v6 (#654)
Reviewed-on: https://gitea.com/gitea/tea/pulls/654
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-20 13:38:07 +00:00
Renovate Bot
18abf24dca 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 <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-20 13:37:49 +00:00
Renovate Bot
7cb6a84098 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 <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-20 13:37:20 +00:00
techknowlogick
7e700e36f8 update template for issue reporting 2024-07-18 18:11:32 +00:00
Renovate Bot
61bdc14184 fix(deps): update module golang.org/x/crypto to v0.25.0 (#652)
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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zODguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQyNC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/652
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-17 01:39:18 +00:00
Renovate Bot
16b37cc6da fix(deps): update module golang.org/x/term to v0.22.0 (#657)
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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjIuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQyMi40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/657
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-16 22:57:03 +00:00
Renovate Bot
b5d7119ab4 fix(deps): update module github.com/adrg/xdg to v0.5.0 (#658)
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

<details>
<summary>adrg/xdg (github.com/adrg/xdg)</summary>

### [`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.

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MjUuMSIsInVwZGF0ZWRJblZlciI6IjM3LjQyNS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/658
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-07-16 22:56:25 +00:00
Renovate Bot
610d04fc85 chore(deps): update ghcr.io/devcontainers/features/git-lfs docker tag to v1.2.0 (#647)
Reviewed-on: https://gitea.com/gitea/tea/pulls/647
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-06-05 05:58:22 +00:00
Renovate Bot
6696e945c6 chore(deps): update mcr.microsoft.com/devcontainers/go docker tag to v1.22 (#648)
Reviewed-on: https://gitea.com/gitea/tea/pulls/648
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-06-05 05:57:56 +00:00
Renovate Bot
5158adbcf2 fix(deps): update module golang.org/x/term to v0.21.0 (#653)
Reviewed-on: https://gitea.com/gitea/tea/pulls/653
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-06-05 05:57:34 +00:00
Lunny Xiao
6e473ec601 Update README.md to add actions badge (#651)
Reviewed-on: https://gitea.com/gitea/tea/pulls/651
2024-05-28 06:21:14 +00:00
Renovate Bot
115f25e85f fix(deps): update module github.com/go-git/go-git/v5 to v5.12.0 (#635)
Reviewed-on: https://gitea.com/gitea/tea/pulls/635
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-05-16 05:59:44 +00:00
Renovate Bot
656d48ec8d fix(deps): update module golang.org/x/crypto to v0.23.0 (#650)
Reviewed-on: https://gitea.com/gitea/tea/pulls/650
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-05-07 14:26:56 +00:00
Renovate Bot
2cb450401c fix(deps): update module code.gitea.io/sdk/gitea to v0.18.0 (#646)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| code.gitea.io/sdk/gitea | require | minor | `v0.17.1` -> `v0.18.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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMDEuNiIsInVwZGF0ZWRJblZlciI6IjM3LjMwMS42IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/646
Reviewed-by: appleboy <appleboy.tw@gmail.com>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-04-19 02:37:59 +00:00
techknowlogick
5236a89d4c Update .gitea/workflows/test-pr.yml 2024-04-08 16:45:15 +00:00
techknowlogick
48d2997a63 Update .gitea/workflows/test-pr.yml 2024-04-08 16:45:05 +00:00
techknowlogick
75a7d4b7cc Update .gitea/workflows/release-tag.yml 2024-04-08 16:43:59 +00:00
techknowlogick
1e3043ce6f Update .gitea/workflows/release-nightly.yml 2024-04-08 16:42:23 +00:00
techknowlogick
218b991069 shorter actions path 2024-04-08 16:41:04 +00:00
techknowlogick
16a3594474 Update .goreleaser.yaml 2024-04-08 16:37:08 +00:00
techknowlogick
b1b31da7c8 Update .goreleaser.yaml 2024-04-08 16:34:15 +00:00
Lunny Xiao
36672485d1 Fix license wrong declare. This project is created by Gitea itself, the license is a copy typo (#640)
Reviewed-on: https://gitea.com/gitea/tea/pulls/640
2024-04-07 03:30:46 +00:00
Renovate Bot
4fedaaafe1 fix(deps): update module golang.org/x/crypto to v0.21.0 (#627)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-03-07 04:04:35 +00:00
Renovate Bot
6ae3718574 fix(deps): update module golang.org/x/term to v0.18.0 (#630)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-03-06 04:38:27 +00:00
Renovate Bot
c4f6231c49 chore(deps): update crazy-max/ghaction-import-gpg action to v6 (#625)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) | action | major | `v5` -> `v6` |

---

### Release Notes

<details>
<summary>crazy-max/ghaction-import-gpg (crazy-max/ghaction-import-gpg)</summary>

### [`v6`](https://github.com/crazy-max/ghaction-import-gpg/compare/v5...v6)

[Compare Source](https://github.com/crazy-max/ghaction-import-gpg/compare/v5...v6)

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMDIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIwMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/625
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-02-23 00:38:08 +00:00
Renovate Bot
76f7f901fc chore(deps): update actions/setup-go action to v5 (#624)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [actions/setup-go](https://github.com/actions/setup-go) | action | major | `v4` -> `v5` |

---

### Release Notes

<details>
<summary>actions/setup-go (actions/setup-go)</summary>

### [`v5`](https://github.com/actions/setup-go/compare/v4...v5)

[Compare Source](https://github.com/actions/setup-go/compare/v4...v5)

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMDIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIwMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/624
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-02-23 00:36:59 +00:00
Renovate Bot
005beca233 chore(deps): update goreleaser/goreleaser-action action to v5 (#626)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) | action | major | `v4` -> `v5` |

---

### Release Notes

<details>
<summary>goreleaser/goreleaser-action (goreleaser/goreleaser-action)</summary>

### [`v5`](https://github.com/goreleaser/goreleaser-action/compare/v4...v5)

[Compare Source](https://github.com/goreleaser/goreleaser-action/compare/v4...v5)

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMDIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIwMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/626
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-02-23 00:35:56 +00:00
Renovate Bot
e62713f42a fix(deps): update module golang.org/x/crypto to v0.19.0 (#622)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-02-19 22:27:48 +00:00
John Olheiser
c8c8e9758b Add OTP and scopes to login (#546)
Resolves #542

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/546
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: John Olheiser <john+gitea@jolheiser.com>
Co-committed-by: John Olheiser <john+gitea@jolheiser.com>
2024-02-14 16:49:29 +00:00
Renovate Bot
d15af88f83 fix(deps): update module golang.org/x/crypto to v0.18.0 (#618)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| golang.org/x/crypto | require | minor | `v0.17.0` -> `v0.18.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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjYuMiIsInVwZGF0ZWRJblZlciI6IjM3LjEyNi4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/618
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-01-15 06:58:30 +00:00
Renovate Bot
c74177556b fix(deps): update module code.gitea.io/sdk/gitea to v0.17.1 (#616)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2024-01-08 19:02:29 +00:00
Renovate Bot
02836d8e52 fix(deps): update module code.gitea.io/sdk/gitea to v0.17.0 (#611)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-12-29 04:02:18 +00:00
Konstantin Podsvirov
b8ad55117a Installation on Windows via MSYS2 (#615)
Add link to package description page.

Reviewed-on: https://gitea.com/gitea/tea/pulls/615
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: Konstantin Podsvirov <podsvirov@noreply.gitea.com>
Co-committed-by: Konstantin Podsvirov <podsvirov@noreply.gitea.com>
2023-12-29 04:01:14 +00:00
Renovate Bot
fb4eb8be9c fix(deps): update module github.com/go-git/go-git/v5 to v5.11.0 (#606)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-12-26 18:36:37 +00:00
Renovate Bot
81b784d7a5 fix(deps): update module golang.org/x/crypto to v0.17.0 (#607)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| golang.org/x/crypto | require | minor | `v0.15.0` -> `v0.17.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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy42OC4wIiwidXBkYXRlZEluVmVyIjoiMzcuMTAyLjAiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/607
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-12-19 02:13:47 +00:00
Renovate Bot
649b0b1272 fix(deps): update module golang.org/x/crypto to v0.15.0 (#603)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-11-09 04:29:12 +00:00
Renovate Bot
3c9552c531 fix(deps): update module github.com/go-git/go-git/v5 to v5.10.0 (#601)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-10-26 01:54:58 +00:00
techknowlogick
f28ddccd90 add snapcraft file (#600)
Reviewed-on: https://gitea.com/gitea/tea/pulls/600
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-10-23 18:36:38 +00:00
Renovate Bot
5beb5bf56b fix(deps): update module golang.org/x/crypto to v0.14.0 (#596)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-10-06 01:52:57 +00:00
Renovate Bot
17e09a3c2d chore(deps): update docker/setup-buildx-action action to v3 (#594)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-29 15:28:21 +00:00
Renovate Bot
58962cbb65 chore(deps): update docker/setup-qemu-action action to v3 (#595)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-29 15:28:02 +00:00
Renovate Bot
7029e7e8c5 chore(deps): update docker/login-action action to v3 (#593)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-28 14:50:50 +00:00
Renovate Bot
3e8047dfe6 chore(deps): update docker/build-push-action action to v5 (#592)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-28 14:50:35 +00:00
techknowlogick
897dc50bfe build and push nightly docker image 2023-09-27 03:03:09 +00:00
Renovate Bot
2f1ca85b25 chore(deps): update actions/checkout action to v4 (#588)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-25 03:39:40 +00:00
Lunny Xiao
e6a6aa6f49 Update documentation about brew and some other misc (#590)
Reviewed-on: https://gitea.com/gitea/tea/pulls/590
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-09-15 02:12:50 +00:00
Renovate Bot
bcda543bb8 fix(deps): update module github.com/go-git/go-git/v5 to v5.9.0 (#589)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-13 18:52:54 +00:00
Sienna Lloyd
9e5db56dcf added migrate command (#587)
Relates to #22, but adds in all the necessary flags. I tested it manually with some scripting and it works as intended.

Signed-off-by: Sienna Lloyd <sienna@linux.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/587
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: Sienna Lloyd <sienna@linux.com>
Co-committed-by: Sienna Lloyd <sienna@linux.com>
2023-09-11 06:27:48 +00:00
techknowlogick
92d49e383d fix readme badges 2023-09-10 18:48:34 +00:00
techknowlogick
2a666c84cb pie doesn't mesh with scratch image 2023-09-10 00:50:04 -04:00
techknowlogick
32b9f5e836 use chainguard images for docker 2023-09-10 00:35:56 -04:00
techknowlogick
33442fd05f rm outdated code from makefile since goreleaser was added 2023-09-10 04:14:38 +00:00
Renovate Bot
f2cf5b7979 fix(deps): update module github.com/urfave/cli/v2 to v2.25.7 (#584)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-10 03:59:02 +00:00
techknowlogick
d80c8ceffd bump to yaml.v3 2023-09-10 03:47:43 +00:00
Renovate Bot
e3b4d68af7 fix(deps): update module gopkg.in/yaml.v2 to v3 (#585)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) | require | major | `v2.4.0` -> `v3.0.1` |

---

### Release Notes

<details>
<summary>go-yaml/yaml (gopkg.in/yaml.v2)</summary>

### [`v3.0.1`](https://github.com/go-yaml/yaml/compare/v3.0.0...v3.0.1)

[Compare Source](https://github.com/go-yaml/yaml/compare/v3.0.0...v3.0.1)

### [`v3.0.0`](https://github.com/go-yaml/yaml/compare/v2.4.0...v3.0.0)

[Compare Source](https://github.com/go-yaml/yaml/compare/v2.4.0...v3.0.0)

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi43OS4xIiwidXBkYXRlZEluVmVyIjoiMzYuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/585
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-09 03:38:09 +00:00
techknowlogick
0df93dd47a bump sdk dep (#583)
Reviewed-on: https://gitea.com/gitea/tea/pulls/583
Co-authored-by: techknowlogick <hello@techknowlogick.com>
Co-committed-by: techknowlogick <hello@techknowlogick.com>
2023-09-08 15:35:38 +00:00
jolheiser
66b4decdd1 feat: devbox (#572)
This PR adds a [devbox](https://www.jetpack.io/devbox/) config to the repo.
This may be beneficial to anyone interested in nix but doesn't want to deal with the language, or anyone interested in an easy way to start development for `tea`.

With `devbox` installed, `devbox shell` should drop you into a shell with `go 1.20.x`, `gopls` (language server), and `make` for build targets available.
I didn't want to duplicate all of our Makefile, but I did add a single script `devbox run build` because it also has the packages above available, so at the very least a user with `devbox` should be able to build the project.

We don't have CGO, so nothing extra should be required that I can think of, and our linters are invoked via `go run` so they should also work since the `go` package would be available.

-----

As a quick note, I am more familiar with nix itself than I am with devbox, but I think this could potentially help anyone wanting to quickly contribute.

If you want to get really meta and are a nix user, you could even run `nix run nixpkgs#devbox shell` to drop into the shell.

Another alternative would be to write an actual flake with a devShell, however I think `devbox` is a nice in-between. Anyone comfortable with nix can probably whip up a dev environment fairly easily without `devbox`.

Co-authored-by: techknowlogick <techknowlogick@noreply.gitea.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/572
Co-authored-by: jolheiser <john.olheiser@gmail.com>
Co-committed-by: jolheiser <john.olheiser@gmail.com>
2023-09-08 15:24:52 +00:00
techknowlogick
9e1919ec0a add devcontainer for tea (#582)
Reviewed-on: https://gitea.com/gitea/tea/pulls/582
Co-authored-by: techknowlogick <hello@techknowlogick.com>
Co-committed-by: techknowlogick <hello@techknowlogick.com>
2023-09-08 15:24:36 +00:00
Renovate Bot
615cd31eb2 fix(deps): update module github.com/muesli/termenv to v0.15.2 (#579)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-08 01:53:03 +00:00
techknowlogick
b868d30434 spdx (#581)
Co-authored-by: techknowlogick <hello@techknowlogick.com>
Co-committed-by: techknowlogick <hello@techknowlogick.com>
2023-09-08 01:40:02 +00:00
Renovate Bot
2d57e07dc7 fix(deps): update module github.com/stretchr/testify to v1.8.4 (#580)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-08 01:06:46 +00:00
Renovate Bot
3343fedc17 fix(deps): update module github.com/alecaivazis/survey/v2 to v2.3.7 (#575)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-08 01:06:28 +00:00
Renovate Bot
f9c67f35a6 fix(deps): update module github.com/charmbracelet/glamour to v0.6.0 (#577)
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-08 01:06:11 +00:00
Renovate Bot
dd8d7fb30f fix(deps): update module code.gitea.io/gitea-vet to v0.2.2 (#574)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| code.gitea.io/gitea-vet | require | patch | `v0.2.1` -> `v0.2.2` |

---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information.

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi43OS4xIiwidXBkYXRlZEluVmVyIjoiMzYuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/574
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-08 01:01:52 +00:00
Renovate Bot
17453fd7cb fix(deps): update module github.com/go-git/go-git/v5 to v5.8.1 (#578)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) | require | minor | `v5.4.2` -> `v5.8.1` |

---

### ⚠ Dependency Lookup Warnings ⚠

Warnings were logged while processing this repo. Please check the Dependency Dashboard for more information.

---

### Release Notes

<details>
<summary>go-git/go-git (github.com/go-git/go-git/v5)</summary>

### [`v5.8.1`](https://github.com/go-git/go-git/releases/tag/v5.8.1)

[Compare Source](https://github.com/go-git/go-git/compare/v5.8.0...v5.8.1)

#### What's Changed

-   \*: Bump dependencies by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/815

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.8.0...v5.8.1

### [`v5.8.0`](https://github.com/go-git/go-git/releases/tag/v5.8.0)

[Compare Source](https://github.com/go-git/go-git/compare/v5.7.0...v5.8.0)

#### What's Changed

-   git: Fix fetching after shallow clone. Fixes [#&#8203;305](https://github.com/go-git/go-git/issues/305) by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/778
-   git: enable fetch with unqualified references by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/762
-   git: don't add to want if exists, shallow and depth 1 by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/763
-   git: Clone HEAD should not force master. Fixes [#&#8203;363](https://github.com/go-git/go-git/issues/363) by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/758
-   git: fix the issue with submodules having the SCP style URL fail due to the wrong URL parsing by [@&#8203;matejrisek](https://github.com/matejrisek) in https://github.com/go-git/go-git/pull/756
-   git: add a clone option to allow for shallow cloning of submodules by [@&#8203;matejrisek](https://github.com/matejrisek) in https://github.com/go-git/go-git/pull/765
-   worktree: minor speedup for `doAddDirectory` by [@&#8203;ThinkChaos](https://github.com/ThinkChaos) in https://github.com/go-git/go-git/pull/702
-   \_examples: Remove wrong comment by [@&#8203;pascal-hofmann](https://github.com/pascal-hofmann) in https://github.com/go-git/go-git/pull/357
-   \*: Handle paths starting with tilde by [@&#8203;ricci2511](https://github.com/ricci2511) in https://github.com/go-git/go-git/pull/808
-   \*: Handle paths starting with ~Username by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/809
-   storage: filesystem/dotgit, add support for tmp_objdir prefix by [@&#8203;L11R](https://github.com/L11R) in https://github.com/go-git/go-git/pull/812
-   plumbing: gitignore, replace user dir in path by [@&#8203;Jleagle](https://github.com/Jleagle) in https://github.com/go-git/go-git/pull/772
-   plumbing: gitignore, fix incorrect parsing. Fixes [#&#8203;500](https://github.com/go-git/go-git/issues/500) by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/781
-   plumbing: http, Fix empty repos on Git v2.41+ by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/802
-   plumbing: packp, A request is not empty if it contains shallows. Fixes [#&#8203;328](https://github.com/go-git/go-git/issues/328) by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/792
-   plumbing: blame, Complete rewrite. Fixes [#&#8203;603](https://github.com/go-git/go-git/issues/603) by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/789
-   plumbing: gitignore, Allow gitconfig to contain a gitignore relative to any user home. Fixes [#&#8203;578](https://github.com/go-git/go-git/issues/578) by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/785

#### New Contributors

-   [@&#8203;Jleagle](https://github.com/Jleagle) made their first contribution in https://github.com/go-git/go-git/pull/772
-   [@&#8203;pascal-hofmann](https://github.com/pascal-hofmann) made their first contribution in https://github.com/go-git/go-git/pull/357
-   [@&#8203;ricci2511](https://github.com/ricci2511) made their first contribution in https://github.com/go-git/go-git/pull/808
-   [@&#8203;L11R](https://github.com/L11R) made their first contribution in https://github.com/go-git/go-git/pull/812

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.7.0...v5.7.1

### [`v5.7.0`](https://github.com/go-git/go-git/releases/tag/v5.7.0)

[Compare Source](https://github.com/go-git/go-git/compare/v5.6.1...v5.7.0)

#### What's Changed

-   \*: Add support for initializing SHA256 repositories by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/707
-   git: add mirror clone option by [@&#8203;aymanbagabas](https://github.com/aymanbagabas) in https://github.com/go-git/go-git/pull/735
-   git: Add support to ls-remote with peeled references. Fixes [#&#8203;749](https://github.com/go-git/go-git/issues/749) by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/750
-   git: fix cloning with branch name by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/755
-   git: Worktree, add check to see if file already checked in. Fixes [#&#8203;718](https://github.com/go-git/go-git/issues/718) by [@&#8203;cbbm142](https://github.com/cbbm142) in https://github.com/go-git/go-git/pull/719
-   git: Worktree, git grep bare repositories by [@&#8203;aymanbagabas](https://github.com/aymanbagabas) in https://github.com/go-git/go-git/pull/728
-   git: Add Depth to SubmoduleUpdateOptions by [@&#8203;matejrisek](https://github.com/matejrisek) in https://github.com/go-git/go-git/pull/754
-   git: Testing, Fix tests not cleaning temp folders by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/769
-   git: remote, add support for a configurable timeout. by [@&#8203;andrewpollock](https://github.com/andrewpollock) in https://github.com/go-git/go-git/pull/753
-   git: Allow Initial Branch to be configurable by [@&#8203;techknowlogick](https://github.com/techknowlogick) in https://github.com/go-git/go-git/pull/764
-   storage: filesystem/dotgit, Improve load packed-refs by [@&#8203;fcharlie](https://github.com/fcharlie) in https://github.com/go-git/go-git/pull/743
-   storage: filesystem, Populate index before use. Fixes [#&#8203;148](https://github.com/go-git/go-git/issues/148) by [@&#8203;AriehSchneier](https://github.com/AriehSchneier) in https://github.com/go-git/go-git/pull/722
-   plumbing: resolve non-external delta references by [@&#8203;ZauberNerd](https://github.com/ZauberNerd) in https://github.com/go-git/go-git/pull/485
-   plumbing/transport: fix regression in scp-like match by [@&#8203;jotadrilo](https://github.com/jotadrilo) in https://github.com/go-git/go-git/pull/715
-   plumbing/transport: Add support for custom proxy settings by [@&#8203;aryan9600](https://github.com/aryan9600) in https://github.com/go-git/go-git/pull/744
-   \*: small fixes across the codebase by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/770
-   \*: bump github.com/cloudflare/circl from 1.1.0 to 1.3.3 by [@&#8203;dependabot](https://github.com/dependabot) in https://github.com/go-git/go-git/pull/776
-   \*: bump dependencies by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/748
-   \*: bump Go version to 1.18 on go.mod by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/774
-   \*: add Codeql workflow and bump dependencies by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/775
-   ci: fix upstream git build for master branch by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/739

#### New Contributors

-   [@&#8203;ZauberNerd](https://github.com/ZauberNerd) made their first contribution in https://github.com/go-git/go-git/pull/485
-   [@&#8203;jotadrilo](https://github.com/jotadrilo) made their first contribution in https://github.com/go-git/go-git/pull/715
-   [@&#8203;fcharlie](https://github.com/fcharlie) made their first contribution in https://github.com/go-git/go-git/pull/743
-   [@&#8203;AriehSchneier](https://github.com/AriehSchneier) made their first contribution in https://github.com/go-git/go-git/pull/755
-   [@&#8203;cbbm142](https://github.com/cbbm142) made their first contribution in https://github.com/go-git/go-git/pull/719
-   [@&#8203;aryan9600](https://github.com/aryan9600) made their first contribution in https://github.com/go-git/go-git/pull/744
-   [@&#8203;matejrisek](https://github.com/matejrisek) made their first contribution in https://github.com/go-git/go-git/pull/754
-   [@&#8203;andrewpollock](https://github.com/andrewpollock) made their first contribution in https://github.com/go-git/go-git/pull/753
-   [@&#8203;techknowlogick](https://github.com/techknowlogick) made their first contribution in https://github.com/go-git/go-git/pull/764

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.6.1...v5.7.0

### [`v5.6.1`](https://github.com/go-git/go-git/releases/tag/v5.6.1)

[Compare Source](https://github.com/go-git/go-git/compare/v5.6.0...v5.6.1)

#### What's Changed

-   plumbing/transport: don't use the `firstErrLine` when it is empty by [@&#8203;ThinkChaos](https://github.com/ThinkChaos) in https://github.com/go-git/go-git/pull/682
-   plumbing/transport: ssh, unable to pass a custom HostKeyCallback func by [@&#8203;aymanbagabas](https://github.com/aymanbagabas) in https://github.com/go-git/go-git/pull/655
-   storage/filesystem: dotgit: fix a filesystem race in Refs/walkReferencesTree by [@&#8203;MichaelMure](https://github.com/MichaelMure) in https://github.com/go-git/go-git/pull/659
-   \*: bump golang.org/x/net from 0.2.0 to 0.7.0 by [@&#8203;dependabot](https://github.com/dependabot) in https://github.com/go-git/go-git/pull/684
-   \*: bump dependencies by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/697
-   \*: fix panic for empty revisions by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/696
-   ci: bump GitHub actions, enable go test race detection and stop using developer's GPG keys during test execution by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/701

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.6.0...v5.6.1

### [`v5.6.0`](https://github.com/go-git/go-git/releases/tag/v5.6.0)

[Compare Source](https://github.com/go-git/go-git/compare/v5.5.2...v5.6.0)

#### What's Changed

-   Worktree, check for empty parent dirs during Reset (Fixes [#&#8203;670](https://github.com/go-git/go-git/issues/670)) by [@&#8203;mbohy](https://github.com/mbohy) in https://github.com/go-git/go-git/pull/671
-   \*: remove need to build with CGO by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/688
-   plumbing: support SSH/X509 signed tags by [@&#8203;hiddeco](https://github.com/hiddeco) in https://github.com/go-git/go-git/pull/690

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.5.2...v5.6.0

### [`v5.5.2`](https://github.com/go-git/go-git/releases/tag/v5.5.2)

[Compare Source](https://github.com/go-git/go-git/compare/v5.5.1...v5.5.2)

#### What's Changed

-   \*: update go-billy v5.4.0, removes data races. Fixes [#&#8203;629](https://github.com/go-git/go-git/issues/629) by [@&#8203;mcuadros](https://github.com/mcuadros) in https://github.com/go-git/go-git/pull/653
-   Worktree: Add, fix add removed files. Fixes [#&#8203;223](https://github.com/go-git/go-git/issues/223) by [@&#8203;tfujiwar](https://github.com/tfujiwar) in https://github.com/go-git/go-git/pull/652

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.5.1...v5.5.2

### [`v5.5.1`](https://github.com/go-git/go-git/releases/tag/v5.5.1)

[Compare Source](https://github.com/go-git/go-git/compare/v5.5.0...v5.5.1)

#### What's Changed

-   \*: fix error when building with `CGO_ENABLED=0` by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/625
-   plumbing: transport/ssh: fix panic on Windows 10 with paegent as ssh-agent by [@&#8203;doxsch](https://github.com/doxsch) in https://github.com/go-git/go-git/pull/617
-   CommitOptions: AllowEmptyCommits, return an error instead of creating empty commits by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/623

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.5.0...v5.5.1

### [`v5.5.0`](https://github.com/go-git/go-git/releases/tag/v5.5.0)

[Compare Source](https://github.com/go-git/go-git/compare/v5.4.2...v5.5.0)

#### What's Changed

-   \*: add collision resistent SHA1 implementation by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/618
-   \*: replace go-homedir with os.UserHomeDir by [@&#8203;mvdan](https://github.com/mvdan) in https://github.com/go-git/go-git/pull/535
-   Remote: add RemoteURL to {Fetch,Pull,Push}Options by [@&#8203;noerw](https://github.com/noerw) in https://github.com/go-git/go-git/pull/375
-   Remote: Push, add support to push commits per hashes by [@&#8203;tjamet](https://github.com/tjamet) in https://github.com/go-git/go-git/pull/325
-   Remote: Push, add ForceWithLease Push Option by [@&#8203;john-cai](https://github.com/john-cai) in https://github.com/go-git/go-git/pull/404
-   Remote: PushOptions add push-options by [@&#8203;S-Bohn](https://github.com/S-Bohn) in https://github.com/go-git/go-git/pull/399
-   Remote: Push, add atomic to push options by [@&#8203;john-cai](https://github.com/john-cai) in https://github.com/go-git/go-git/pull/406
-   Remote: add FollowTags option for pushes by [@&#8203;john-cai](https://github.com/john-cai) in https://github.com/go-git/go-git/pull/385
-   Worktree: use syscall.Timespec.Unix by [@&#8203;tklauser](https://github.com/tklauser) in https://github.com/go-git/go-git/pull/437
-   Worktree: Checkout, simplified sparse checkout by [@&#8203;john-cai](https://github.com/john-cai) in https://github.com/go-git/go-git/pull/410
-   Repository: don't crash accessing invalid pathinfo by [@&#8203;muesli](https://github.com/muesli) in https://github.com/go-git/go-git/pull/443
-   storage: filesystem, switch from os.SEEK_\* to io.Seek\* by [@&#8203;abhinav](https://github.com/abhinav) in https://github.com/go-git/go-git/pull/421
-   config: add branch description support by [@&#8203;ninedraft](https://github.com/ninedraft) in https://github.com/go-git/go-git/pull/409
-   revision: fix endless looping in revision parser by [@&#8203;michenriksen](https://github.com/michenriksen) in https://github.com/go-git/go-git/pull/475
-   pumbling: optimise zlib reader and consolidate sync.Pools by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/608
-   pumbling: parse optimisations by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/602
-   plumbing: object, rename calculation uses too much memory by [@&#8203;jfontan](https://github.com/jfontan) in https://github.com/go-git/go-git/pull/503
-   plumbing: protocol/pakp and server, include the contents of `GO_GIT_USER_AGENT_EXTRA`. Fixes [#&#8203;529](https://github.com/go-git/go-git/issues/529) by [@&#8203;stewing](https://github.com/stewing) in https://github.com/go-git/go-git/pull/531
-   plumbing: protocol/pakp, avoid duplicate encoding when overriding a Capability value. by [@&#8203;tylerchr](https://github.com/tylerchr) in https://github.com/go-git/go-git/pull/521
-   plumbing: protocol/pakp, update agent by [@&#8203;caarlos0](https://github.com/caarlos0) in https://github.com/go-git/go-git/pull/453
-   plumbing: protocol/pakp: Actions should have type Action by [@&#8203;abhinav](https://github.com/abhinav) in https://github.com/go-git/go-git/pull/420
-   plumbing: protocol/pakp: allow unsupported `multi_ack` capability by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/613
-   plumbing: transport/ssh, auto-populate HostKeyAlgorithms. Fixes [#&#8203;411](https://github.com/go-git/go-git/issues/411) by [@&#8203;evanelias](https://github.com/evanelias) in https://github.com/go-git/go-git/pull/548
-   pumbling: format/packfile, resolve external reference delta by [@&#8203;ga-paul-t](https://github.com/ga-paul-t) in https://github.com/go-git/go-git/pull/392
-   plumbing: format/packfile, prevent large objects from being read into memory completely by [@&#8203;zeripath](https://github.com/zeripath) in https://github.com/go-git/go-git/pull/330
-   plumbing: format/index, support v3 index by [@&#8203;john-cai](https://github.com/john-cai) in https://github.com/go-git/go-git/pull/407
-   plumbing: format/gitignore, Read .git/info/exclude file too. by [@&#8203;enisdenjo](https://github.com/enisdenjo) in https://github.com/go-git/go-git/pull/402
-   plumbing: format/gitattributes, Avoid index out of range  by [@&#8203;To1ne](https://github.com/To1ne) in https://github.com/go-git/go-git/pull/598
-   plumbing: format/config, Branch name with hash can be cloned. Fixes [#&#8203;309](https://github.com/go-git/go-git/issues/309) by [@&#8203;dowy](https://github.com/dowy) in https://github.com/go-git/go-git/pull/354
-   go.mod: update github.com/xanzy/ssh-agent to v0.3.1 by [@&#8203;tklauser](https://github.com/tklauser) in https://github.com/go-git/go-git/pull/403
-   go.mod: update dependencies to remove supply chain CVEs by [@&#8203;pjbgf](https://github.com/pjbgf) in https://github.com/go-git/go-git/pull/620
-   examples: added "tag find if head is tagged" by [@&#8203;snebel29](https://github.com/snebel29) in https://github.com/go-git/go-git/pull/374
-   examples: remote fix typo by [@&#8203;nep-0](https://github.com/nep-0) in https://github.com/go-git/go-git/pull/408

**Full Changelog**: https://github.com/go-git/go-git/compare/v5.4.2...v5.5.0

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi43OS4xIiwidXBkYXRlZEluVmVyIjoiMzYuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/578
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-08 01:01:32 +00:00
Renovate Bot
fe4551142a Configure Renovate (#573)
Welcome to [Renovate](https://github.com/renovatebot/renovate)! This is an onboarding PR to help you understand and configure settings before regular Pull Requests begin.

🚦 To activate Renovate, merge this Pull Request. To disable Renovate, simply close this Pull Request unmerged.

---
### Detected Package Files

 * `Dockerfile` (dockerfile)
 * `go.mod` (gomod)

### Configuration Summary

Based on the default config's presets, Renovate will:

  - Start dependency updates only once this onboarding PR is merged
  - Enable Renovate Dependency Dashboard creation.
  - Use semantic commit type `fix` for dependencies and `chore` for all others if semantic commits are in use.
  - Ignore `node_modules`, `bower_components`, `vendor` and various test/tests directories.
  - Group known monorepo packages together.
  - Use curated list of recommended non-monorepo package groupings.
  - Apply crowd-sourced package replacement rules.
  - Apply crowd-sourced workarounds for known problems with packages.
  - Pin Docker digests.

🔡 Would you like to change the way Renovate is upgrading your dependencies? Simply edit the `renovate.json5` in this branch with your custom config and the list of Pull Requests in the "What to Expect" section below will be updated the next time Renovate runs.

---

### What to Expect

With your current configuration, Renovate will create 12 Pull Requests:

<details>
<summary>chore(deps): pin golang docker tag to 46571ac</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/pin-dependencies`
  - Merge into: `main`
  - Upgrade golang to `sha256:46571ac5f5f793cae20df72cc6f29b155eeba6e6b4377eccc641f84880529986`

</details>

<details>
<summary>fix(deps): update module code.gitea.io/gitea-vet to v0.2.2</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/code.gitea.io-gitea-vet-0.x`
  - Merge into: `main`
  - Upgrade code.gitea.io/gitea-vet to `v0.2.2`

</details>

<details>
<summary>fix(deps): update module github.com/alecaivazis/survey/v2 to v2.3.7</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/github.com-alecaivazis-survey-v2-2.x`
  - Merge into: `main`
  - Upgrade [github.com/AlecAivazis/survey/v2](https://github.com/AlecAivazis/survey) to `v2.3.7`

</details>

<details>
<summary>chore(deps): update golang docker tag to v1.21.1</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/golang-1.x`
  - Merge into: `main`
  - Upgrade golang to `sha256:96634e55b363cb93d39f78fb18aa64abc7f96d372c176660d7b8b6118939d97b`

</details>

<details>
<summary>fix(deps): update module github.com/charmbracelet/glamour to v0.6.0</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/github.com-charmbracelet-glamour-0.x`
  - Merge into: `main`
  - Upgrade [github.com/charmbracelet/glamour](https://github.com/charmbracelet/glamour) to `v0.6.0`

</details>

<details>
<summary>fix(deps): update module github.com/go-git/go-git/v5 to v5.8.1</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/github.com-go-git-go-git-v5-5.x`
  - Merge into: `main`
  - Upgrade [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) to `v5.8.1`

</details>

<details>
<summary>fix(deps): update module github.com/muesli/termenv to v0.15.2</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/github.com-muesli-termenv-0.x`
  - Merge into: `main`
  - Upgrade [github.com/muesli/termenv](https://github.com/muesli/termenv) to `v0.15.2`

</details>

<details>
<summary>fix(deps): update module github.com/stretchr/testify to v1.8.4</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/github.com-stretchr-testify-1.x`
  - Merge into: `main`
  - Upgrade [github.com/stretchr/testify](https://github.com/stretchr/testify) to `v1.8.4`

</details>

<details>
<summary>fix(deps): update module github.com/urfave/cli/v2 to v2.25.7</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/github.com-urfave-cli-v2-2.x`
  - Merge into: `main`
  - Upgrade [github.com/urfave/cli/v2](https://github.com/urfave/cli) to `v2.25.7`

</details>

<details>
<summary>fix(deps): update module golang.org/x/crypto to v0.13.0</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/golang.org-x-crypto-0.x`
  - Merge into: `main`
  - Upgrade golang.org/x/crypto to `0d375be9b61cb69eb94173d0375a05e90875bbf6`

</details>

<details>
<summary>fix(deps): update module golang.org/x/term to v0.12.0</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/golang.org-x-term-0.x`
  - Merge into: `main`
  - Upgrade golang.org/x/term to `f413282cd8dbb55102093d9f16ab3ba90f7b9b31`

</details>

<details>
<summary>fix(deps): update module gopkg.in/yaml.v2 to v3</summary>

  - Schedule: ["at any time"]
  - Branch name: `renovate/gopkg.in-yaml.v2-3.x`
  - Merge into: `main`
  - Upgrade [gopkg.in/yaml.v2](https://github.com/go-yaml/yaml) to `v3.0.1`

</details>

<br />

🚸 Branch creation will be limited to maximum 2 per hour, so it doesn't swamp any CI resources or overwhelm the project. See docs for `prhourlylimit` for details.

---

### ⚠ Dependency Lookup Warnings ⚠

Please correct - or verify that you can safely ignore - these lookup failures before you merge this PR.

-   `Could not determine new digest for update (datasource: go)`

Files affected: `go.mod`

---

 Got questions? Check out Renovate's [Docs](https://docs.renovatebot.com/), particularly the Getting Started section.
If you need any further assistance then you can also [request help here](https://github.com/renovatebot/renovate/discussions).

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

<!--renovate-config-hash:b0e8c3aba9246cf9ec209c46e593f123f2daeea739622a97656e285413290a78-->

Reviewed-on: https://gitea.com/gitea/tea/pulls/573
Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
Co-committed-by: Renovate Bot <renovate-bot@gitea.com>
2023-09-07 23:08:07 +00:00
mvaldes14
10bd00d066 adding installer option with asdf (#563)
created a plugin to install tea via asdf - hoping someone else can find it useful.

Co-authored-by: mvaldes <mvaldes.revilla@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/563
Co-authored-by: mvaldes14 <mvaldes14@noreply.gitea.com>
Co-committed-by: mvaldes14 <mvaldes14@noreply.gitea.com>
2023-09-01 15:34:42 +00:00
jolheiser
0869c15a6c Initial CLI docs (#565)
As title, then we could potentially start ingesting these in the docs repo as they are expanded.

Reviewed-on: https://gitea.com/gitea/tea/pulls/565
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: jolheiser <john.olheiser@gmail.com>
Co-committed-by: jolheiser <john.olheiser@gmail.com>
2023-09-01 15:34:13 +00:00
Martin Veldwijk
e4e8eb07d2 Fix for go tools called from make (#568)
Fixes #567 by offloading the `$PATH` interpolation to the shell instead of letting make handle it.
Tested and works on Linux, tested and works on Windows using MSYS2/MingW64. Not tested on a pure Windows env without translation layers, but nothing was changed that would actively break it either.

Reviewed-on: https://gitea.com/gitea/tea/pulls/568
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Martin Veldwijk <riven@tae.moe>
Co-committed-by: Martin Veldwijk <riven@tae.moe>
2023-08-21 22:01:15 +00:00
John Olheiser
620f236723 Update issue template for dl.gitea.com
Signed-off-by: John Olheiser <john+gitea@jolheiser.com>
2023-08-01 14:53:10 +00:00
Martin Veldwijk
77837e909e Fix Makefile for Windows builds (#566)
Fixes #564 (/gitea/tea/issues/564) by applying minor changes to the Makefile.
- Defines a `BINEXT` variable which holds a file name extension (.exe for Windows, empty otherwise)
- Replaces uses of `$(EXECUTABLE)` with `tea$(EXECUTABLE)`
- appends `$(BINEXT)` to the custom vet tool flag

Besides that I made two minor changes
- Add `[.exe]` to the ignore rule for gitea-vet, so it also ignores the binary when built on Windows hosts
- Removed `$(DIST)/binaries` from release-dirs as this is not being called anywhere else

I've tested almost all `make` tasks to work on Windows. The only one I haven't run is the docker build.

WIP tag is because I still have to test it on Linux, will do so in a bit. I also asked for some discussion on the original issue, which I'd like to do before blindly asking to merge in changes

Reviewed-on: https://gitea.com/gitea/tea/pulls/566
Co-authored-by: Martin Veldwijk <riven@tae.moe>
Co-committed-by: Martin Veldwijk <riven@tae.moe>
2023-07-28 14:03:26 +00:00
6543
5582f92df4 fix interactive login add (#557)
if you just hit "enter" the loginMethod is `` so this coves that case

Reviewed-on: https://gitea.com/gitea/tea/pulls/557
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2023-06-07 16:47:52 +00:00
vsysoev
c72c6c0679 issues list can show filtered by owner/org instead of repo too (#550)
close #551

Co-authored-by: Sysoev, Vladimir <vladimir.sysoev@sarov-itc.ru>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/550
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: vsysoev <vsysoev@noreply.gitea.com>
Co-committed-by: vsysoev <vsysoev@noreply.gitea.com>
2023-06-06 13:25:36 +00:00
Grady Wong
b2d845b8c7 fix: non-standard ssh port URL's repo can't be recognized (#555)
Resolve #452

Reviewed-on: https://gitea.com/gitea/tea/pulls/555
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Grady Wong <wgqimut@gmail.com>
Co-committed-by: Grady Wong <wgqimut@gmail.com>
2023-06-06 13:14:21 +00:00
Bo-Yi Wu
07039b82e3 ci: improve release process and test coverage (#553)
- Add extra_files configuration to .goreleaser.yaml
- Include .xz and .xz.sha256 files in the release

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

Reviewed-on: https://gitea.com/gitea/tea/pulls/553
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-committed-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2023-05-04 11:58:15 +08:00
appleboy
7040c350ae build: optimize compression method and clean up environment variables (#552)
- Replace tar command with xz command for compression
- Remove redundant environment variable XZ_OPT

ref: https://gitea.com/gitea/homebrew-gitea/pulls/164

Signed-off-by: appleboy <appleboy.tw@gmail.com>

Reviewed-on: https://gitea.com/gitea/tea/pulls/552
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2023-05-01 21:59:26 +08:00
appleboy
b02263adb0 refactor: improve code quality and efficiency in various files (#548)
- Replace loadConfig() with _ = loadConfig()
- Update file permissions from 0660 to 0o660
- Simplify variable declarations
- Replace golang.org/x/crypto/ssh/terminal with golang.org/x/term
- Remove unused getCertPrincipals function
- Replace time.Now().Sub() with time.Since()
- Add test for ArgToIndex function

Signed-off-by: appleboy <appleboy.tw@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/548
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2023-04-30 11:43:26 +08:00
appleboy
4915862b95 refactor: optimize PR title generation and expand test coverage (#549)
- Import "regexp" package in pull_create.go
- Replace existing code for `GetDefaultPRTitle` with a more efficient regular expression approach
- Add a new test file pull_create_test.go with a test function for `GetDefaultPRTitle`

Signed-off-by: appleboy <appleboy.tw@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/549
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2023-04-30 00:16:18 +08:00
appleboy
cd6a7b35c3 ci: improve build process and test coverage (#547)
- Add `dir: ./dist/` to the builds section in `.goreleaser.yaml`

ref: https://gitea.com/gitea/act_runner/issues/158

Signed-off-by: appleboy <appleboy.tw@gmail.com>

Reviewed-on: https://gitea.com/gitea/tea/pulls/547
Reviewed-by: Jason Song <i@wolfogre.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: appleboy <appleboy.tw@gmail.com>
Co-committed-by: appleboy <appleboy.tw@gmail.com>
2023-04-29 08:29:24 +08:00
ASDFGamer
abcaa58312 Improve Compilation Section in Readme (#543)
This PR adds two small improvements to the compilation Section of the Readme:

- Add go/The Go Programming Language to the list of required tools in the compilation section of the readme.
- Add a short explanation how the compiled source can be installed via make install, with a note about the GOPATH

Co-authored-by: Christoph Wildhagen <git@christoph-wildhagen.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/543
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: ASDFGamer <asdfgamer@noreply.gitea.io>
Co-committed-by: ASDFGamer <asdfgamer@noreply.gitea.io>
2023-04-19 03:06:00 +08:00
ASDFGamer
d9da952e96 Output full path to go bin directory during installation (#544)
This fixed a Bug, that a wrong directory could be written to shell via
@echo, when the env var GOPATH isn't set.

Co-authored-by: Christoph Wildhagen <git@christoph-wildhagen.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/544
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: ASDFGamer <asdfgamer@noreply.gitea.io>
Co-committed-by: ASDFGamer <asdfgamer@noreply.gitea.io>
2023-04-18 05:08:50 +08:00
Lunny Xiao
7f335a2b9c Update '.gitea/workflows/release-tag.yml' (#541)
Reviewed-on: https://gitea.com/gitea/tea/pulls/541
Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-04-13 22:54:46 +08:00
6543
b510756438 If gitea version is not detected, just fall back to last supported one and print warning (#538)
close #531

Reviewed-on: https://gitea.com/gitea/tea/pulls/538
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-04-03 13:49:33 +08:00
techknowlogick
3640bbac5e gpg fingerprint 2023-03-29 22:44:01 -04:00
techknowlogick
b705188599 Switch CI to Actions and use Goreleaser (#536)
Reviewed-on: https://gitea.com/gitea/tea/pulls/536
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-committed-by: techknowlogick <techknowlogick@gitea.io>
2023-03-30 10:24:03 +08:00
6543
cfce25f0a7
followup to: use secrets for s3 info (#530) 2023-02-16 00:14:31 +01:00
6543
e783f4ea4a
Changelog for v0.9.1 (#535)
Reviewed-on: https://gitea.com/gitea/tea/pulls/535
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
2023-02-15 23:23:12 +01:00
John Olheiser
342b573d45 Remove vendor docs (#534)
As title, we no longer use vendoring (or dep!).

Also updated the link to Discord.

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/534
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: John Olheiser <john+gitea@jolheiser.com>
Co-committed-by: John Olheiser <john+gitea@jolheiser.com>
2023-02-09 12:41:43 +08:00
Lunny Xiao
1a6d9b343a Fix makefile vendor problem (#533)
Replace #532

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-on: https://gitea.com/gitea/tea/pulls/533
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-09 11:05:39 +08:00
techknowlogick
faa9858a7e use secrets for s3 info (#530)
Reviewed-on: https://gitea.com/gitea/tea/pulls/530
2023-02-08 05:53:05 +08:00
techknowlogick
e51eb1a00e bump to go 1.20 (#529)
Reviewed-on: https://gitea.com/gitea/tea/pulls/529
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-08 05:46:31 +08:00
Wim
6a848cb72a Add option to disable version checking (#520)
Fixes "Only signed in user is allowed to call APIs." as the
/api/v1/version returns a 403 when running a gitea where
REQUIRE_SIGNIN_VIEW is enabled

Co-authored-by: Wim <wim@42.be>
Reviewed-on: https://gitea.com/gitea/tea/pulls/520
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Wim <42wim@noreply.gitea.io>
Co-committed-by: Wim <42wim@noreply.gitea.io>
2022-10-31 09:56:23 +08:00
Norwin
2a8c1daa67 Add tea issue edit (#506)
fixes #229
fixes #502

interactive mode will be in a follow up

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/506
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-10-25 08:40:00 +08:00
6543
54b535a527 Find DefaultPRHead based on branch and SHA (#514)
Reviewed-on: https://gitea.com/gitea/tea/pulls/514
Reviewed-by: strk <strk@noreply.gitea.io>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
2022-10-25 06:38:39 +08:00
6543
c1c7870ceb Handle Team Reviews (#515)
at the moment we crash with an nil exeption if there exist team reviews

this fix it and add support to display them

Reviewed-on: https://gitea.com/gitea/tea/pulls/515
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: wxiaoguang <wxiaoguang@noreply.gitea.io>
2022-09-29 10:49:24 +08:00
6543
a37377d181 Add "json" as output type (#513)
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/513
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: strk <strk@noreply.gitea.io>
2022-09-27 23:39:47 +08:00
6543
15457f1770 Add Allow Maintainer Edits (#509)
close #508

Reviewed-on: https://gitea.com/gitea/tea/pulls/509
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: strk <strk@noreply.gitea.io>
2022-09-27 23:36:36 +08:00
Norwin
4487213581 Allow batch operations on multiple entities (#512)
commands now accept multiple arguments where it makes sense.

#### before
```
NAME:
   tea issues close - Change state of an issue to 'closed'

USAGE:
   tea issues close [command options] <issue index>
```

#### after
```
NAME:
   tea issues close - Change state of one ore more issues to 'closed'

USAGE:
   tea issues close [command options] <issue index> [<issue index>...]
```

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/512
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-09-27 04:35:59 +08:00
Wim
6a4ba6a689 Add support for authentication via ssh certificates and pub/privatekey (#442)
This adds support for authentication using a SSH certificate and normal public keys when you've got an ssh-agent running that has this certificate or your public key loaded.

First question when creating a new login is to ask about the ssh certificates or public keys, when the answer is yes, we don't need to ask about tokens/usernames anymore.

Co-authored-by: Wim <wim@42.be>
Reviewed-on: https://gitea.com/gitea/tea/pulls/442
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Wim <42wim@noreply.gitea.io>
Co-committed-by: Wim <42wim@noreply.gitea.io>
2022-09-15 03:00:08 +08:00
6543
4ee5ce4b52 Fix "go install" example (#505)
because some wrong tagging was done in the past, `latest` will point to `1.3.3` witch is actually v0.1.x.

so you have to specify the version

Reviewed-on: https://gitea.com/gitea/tea/pulls/505
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2022-09-14 09:08:41 +08:00
6543
6c9b2f8745
move s3 endpoint to secrets 2022-09-13 22:36:45 +02:00
Norwin
1a256291dc Changelog 0.9.0 (#503)
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/503
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
2022-09-14 03:52:46 +08:00
techknowlogick
832136b6d4 Add user list command (#427)
Co-authored-by: Matti R <matti@mdranta.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/427
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-committed-by: techknowlogick <techknowlogick@gitea.io>
2022-09-14 03:49:34 +08:00
Norwin
99e49991bb Add --fields to notification & milestone listings (#422)
Together with #415 this finally adds the field flag to all entity listings.
closes #342

### ⚠️ breaking changes ⚠️
This changes the column names of `tea milestones ls`:

```diff
 - TITLE  | OPEN/CLOSED ISSUES | DUEDATE
 + TITLE  | ITEMS | DUEDATE
```

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/422
Reviewed-by: delvh <dev.lh@web.de>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-09-14 03:08:18 +08:00
Norwin
bbb287e29e markdown: dont emit ansi sequences when not emitting to tty (#491)
Allows generating a plain text version of an issue (i.e. without colors and other terminal formatting) when storing stdout in a file.
```
tea issue --comments 1 > issue1.txt
```

`IsInteractive()` had to be moved to avoid a recursive import chain.

---

In the future, it would be nice to also respect the `--output` flag. This flag is currently designed for tabular output, but we could add more supported values like `markdown` `ansi`, `plain` to it

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/491
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: delvh <dev.lh@web.de>
2022-09-14 02:35:15 +08:00
Norwin
5e7c702e07 Clarify command descriptions when no arguments are taken (#496)
This changes the command help string from eg
```
NAME:
   tea label create - Create a label

USAGE:
   tea label [command options] [arguments...]
```
to
```
NAME:
   tea label create - Create a label

USAGE:
   tea label [command options]
```

Hopefully improving usability.

---

edit: this also changes `tea release create` to take the `--tag` flag value optionally via the first argument, as this seems to be a clear UX improvement.

fixes #483

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/496
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: delvh <delvh@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-09-14 02:14:02 +08:00
Norwin
b8dbf899d2 Update dependencies (#501)
- The go-sdk update fixes #463

- To review the other updates:
  - glamour [changelog](https://github.com/charmbracelet/glamour/releases), [diff](https://github.com/charmbracelet/glamour/compare/v0.3.0...v0.5.0)
    - enhancement: we now can use `WithPreservedNewLines()` to render markdow the same way as the web ui
  - termenv [changelog](https://github.com/muesli/termenv/releases), [diff](https://github.com/muesli/termenv/compare/v0.9.0...v0.12.0)
    - enhancement: correct feature detection for more terminals
  - xdg [changelog](https://github.com/adrg/xdg/releases), [diff](https://github.com/adrg/xdg/compare/v0.3.3...v0.4.0)
    - no notable changes for us, but good to stay up to date 🤷
  - survey [changelog](https://github.com/AlecAivazis/survey/releases), [diff](https://github.com/AlecAivazis/survey/compare/v2.3.1...v2.3.6)
    - bugfixes
  - cli [changelog](https://github.com/urfave/cli/releases), [diff](https://github.com/urfave/cli/compare/v2.3.0...v2.16.3)
    - bugfixes?

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/501
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-09-14 01:52:44 +08:00
Norwin
0b8be54186 Rename master branch to main (#495)
This updates drone CI to use the new main branch name `main`.

### ⚠️ breaking

The download URLs on https://dl.gitea.io/tea/master will no longer be updated.

@Owners: is there a way to add a redirect for these URLs from `/tea/master` to `/tea/main`?

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/495
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-08-26 23:34:40 +08:00
Norwin
2b1bca9e5d Add license for gitea.com/noerw/unidiff-comments (#493)
The updated version just clarifies the license to be MIT, as [added by the original author](865648740d).
fixes #492

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/493
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: John Olheiser <john+gitea@jolheiser.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-08-22 21:14:09 +08:00
Norwin
d5a258213d Fix CI: disable package-comments lint rule (#494)
There was an unintended change to the rule in revive that now makes our CI trip:
https://github.com/mgechev/revive/pull/694
The package-comments now expected are not really worth writing as these are tiny internal packages, so this change just disables that rule for now.

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/494
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-08-22 20:53:19 +08:00
6543
f83f579dea Show more version info (#486)
Reviewed-on: https://gitea.com/gitea/tea/pulls/486
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Wim <42wim@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2022-06-18 22:34:18 +08:00
6543
65535bd948 Use latest go-sdk and bump golang to 1.18 (#485)
Reviewed-on: https://gitea.com/gitea/tea/pulls/485
Reviewed-by: KN4CK3R <kn4ck3r@noreply.gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2022-06-10 22:31:24 +08:00
Sandro
02f5f15269 Fix go install for go 1.17 (#481)
Reviewed-on: https://gitea.com/gitea/tea/pulls/481
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Sandro <supersandro2000@noreply.gitea.io>
Co-committed-by: Sandro <supersandro2000@noreply.gitea.io>
2022-04-26 14:07:15 +08:00
Norwin
883a27b14e Fetch all items where needed. (#475)
Disable pagination in all places where we need all items.
Ideally we'd do multiple paginated requests until the needed items are local, but this is blocked by https://gitea.com/gitea/go-sdk/pulls/473. So this is a stopgap to get correct behaviour.

Fixes #464

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/475
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-04-08 03:44:16 +08:00
6543
e54b32493d fix pipeline to release builds (#479)
fix regression of #478

Reviewed-on: https://gitea.com/gitea/tea/pulls/479
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
2022-03-29 08:29:47 +08:00
Norwin
329200b1ef Fix running in repos without remote (#472)
For tea, the case of no remotes in the local repo context is equal to `errNotAGiteaRepo`.
This error type is already gracefully handled, so with this change, tea doesn't reject working from a repo without remotes.

fixes #455, closes #465

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/472
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-29 08:01:37 +08:00
Norwin
6663d9f19b Add preference flag_defaults.remote, refactor (#466)
This is a refactor of the code last touched in #458, making the control flow less backwards.

Additionally, this adds a preference `preferences.flag_defaults.remote` that allows to skip this heuristic and set a custom fixed default value for the `--remote` flag.
I'm not sure this is actually needed, I can revert that commit.

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Reviewed-on: https://gitea.com/gitea/tea/pulls/466
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-29 07:34:14 +08:00
6543
d06f35482e Use golang v1.18 and drop vendor folder (#478)
* remove vendor folder
* use golang v1.18 in ci
* use "go install"
* use vendor folder as cache

Reviewed-on: https://gitea.com/gitea/tea/pulls/478
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
2022-03-29 07:11:11 +08:00
Norwin
9ab36c55fa Return RFC3339 UTC timestamps for machine-readable output (#470)
### ⚠️ breaking changes ⚠️

- unset timestamps will not be printed as `"0001-01-01 00:00"`, but as empty value `""`
- output formats `csv`, `tsv`, `yaml` output timestamps in UTC instead of local time, and adhere to [RFC3339](https://datatracker.ietf.org/doc/html/rfc3339)

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/470
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-29 06:37:13 +08:00
6543
40e606561f
GOPROXY: https://goproxy.io 2022-03-28 23:59:48 +02:00
Norwin
0970b94552 Fix context requirements of subcommands (#474)
`tea repo fork` and `tea pr checkout` were missing the requirement of a remote repo.

fixes https://gitea.com/gitea/tea/issues/444

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/474
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-26 15:32:53 +08:00
Norwin
dda94a5dea Refactor errorhandling in getReleaseByTag() (#477)
small refactor for consistency

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/477
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-25 21:41:08 +08:00
Norwin
16ba594a28 Interactive issue/pr posting: properly fetch assignees (#476)
Gitea 1.15.0 added a proper API for listing assignee candidates.
imho that release is old enough that tea can start using this without workarounds.

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/476
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-19 19:08:58 +08:00
Norwin
d8f4273ed0 Add TSV to machine-readable formats (#467)
...so no ansi formatting (colors) is emitted in that format (eg `tea labels -o tsv`)

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/467
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-13 12:00:21 +08:00
Norwin
637e3f0666 Fix CI: run make fmt (#469)
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/469
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2022-03-13 08:53:18 +08:00
techknowlogick
ced24ccabb update to new s3 location (#468)
Reviewed-on: https://gitea.com/gitea/tea/pulls/468
2022-03-11 05:01:29 +08:00
arkamar
fb3e1f75e9 Prefer origin if there are multiple remotes (#458)
Usually, `origin` is the name of a default remote, which corresponds with upstream. This change improves remote selection when non of `main`, `master` nor `trunk` local branches is present.

Co-authored-by: Petr Vaněk <arkamar@atlas.cz>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/458
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: arkamar <arkamar@noreply.gitea.io>
Co-committed-by: arkamar <arkamar@noreply.gitea.io>
2022-03-09 09:35:51 +08:00
Lunny Xiao
0e24009fe9 Fix create milestone with deadline bug (#462)
Fix #461

Reviewed-on: https://gitea.com/gitea/tea/pulls/462
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-09 08:47:58 +08:00
arkamar
cd24fd8e28 Fix few typos in contribution guidelines (#459)
I found few typos in `CONTRIBUTING.md` file.

Co-authored-by: Petr Vaněk <arkamar@atlas.cz>
Reviewed-on: https://gitea.com/gitea/tea/pulls/459
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: arkamar <arkamar@noreply.gitea.io>
Co-committed-by: arkamar <arkamar@noreply.gitea.io>
2022-02-22 22:34:58 +08:00
Ikko Ashimine
dd300c1269 Fix typo in bug.md (#460)
occured -> occurred

Reviewed-on: https://gitea.com/gitea/tea/pulls/460
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Ikko Ashimine <eltociear@noreply.gitea.io>
Co-committed-by: Ikko Ashimine <eltociear@noreply.gitea.io>
2022-02-20 00:30:58 +08:00
kellya
44c9e7e664 Correct spelling of "wether" to "whether" in usage output (#453)
Noticed "whether" misspelled as "wether" in the output of `tea issues --help` and corrected it in a few locations.

Co-authored-by: Alex Kelly <kellya@arachnitech.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/453
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: kellya <kellya@noreply.gitea.io>
Co-committed-by: kellya <kellya@noreply.gitea.io>
2022-02-01 07:11:37 +08:00
Norwin
268aa06179 Add bug report issue template (#448)
As we repeatedly ask for information about users' environments, I added this template

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/448
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-12-04 11:20:36 +08:00
Norwin
a7d83ee416 Simplify build & update installation instructions (#437)
- "revert" the work done in #349. It turns out that this elaborate workaround to get statically built PIEs was only needed due to a bug in go, which got fixed in go 1.16.
- Add an exception to the `-buildmode=pie` flag for OpenBSD, as discovered in #436
- Simplify & update README installation instructions (the Arch AUR package got deleted as it wasn't maintained, so we link to `gitea-tea-git` now.)

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/437
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-12-03 04:01:10 +08:00
Norwin
a89f51f9ec Implement more issue filters (#400)
This adds new filters to `tea issues ls` and `tea pr ls`, made available in SDK 0.15:

```
--state value                 Filter by state (all|open|closed) (default: open)
--keyword value, -k value     Filter by search string
--labels value, -L value      Comma-separated list of labels to match issues against.
--milestones value, -m value  Comma-separated list of milestones to match issues against.
--author value, -A value
--assignee value, -a value
--mentions value, -M value
--from value, -F value        Filter by activity after this date
--until value, -u value       Filter by activity before this date
```

Note: I felt free to change parameter names as exposed by SDK & API, as the names exposed by them are partially bollocks (eg `mentioned_by`) and or inconsistent with usage in other commands (eg `tea times --until`)

fixes #376, related #323

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/400
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-12-03 03:26:48 +08:00
Norwin
d2295828d0 Fix resolving of URLs in markdown (#401)
Path-only URLs need an absolute reference to be resolved against for printing in markdown
Previously we resolved against the URL to the resource we were operating on (eg comment or issue URL).
The markdown renderer in the web UI resolves all such URLs relative to the repo base URL. This PR adopts this behaviour in tea, by trimming the URL to a repo base URL via regex.

This makes a custom patch to our markdown renderer `glamour` obsolete, which turned out to be an incorrect patch, meaning we can make use of upstream glamour again.

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/401
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-12-03 02:59:02 +08:00
Norwin
dc16643e0d Improve Documentation (#433)
- document more assumptions about usage context of gitea
- improve some flag descriptions (#432, #377)

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/433
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-12-03 02:33:56 +08:00
Norwin
ac25e89ebf Add tea repo create-from-template (#408)
I went with a new subcommand instead of `tea repo create --template`, as the options are quite different (bool instead of values, partially different set)

fixes #362

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/408
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-10-20 09:31:35 +08:00
Norwin
819cc1ab21 Add tea clone (#411)
Adds a new subcommand to clone repos:
```
tea clone --login try --depth 1 norwin/test
tea clone gitea/tea
tea clone noerw/tea           # will set up `master` to track `upstream` remote
tea clone try.gitea.io/noerw/test # will automatically set --login
```

This is just a replacement for `git clone` with small benefits:
- [x] does not depend on `git`, as tea ships with go-git
- [x] spares you typing of URLs and autoselects https/ssh based on your login config
- [x] forked repos: set up origin + upstream remote

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-on: https://gitea.com/gitea/tea/pulls/411
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-10-18 20:09:27 +08:00
Norwin
78a95f1ca4 Allow editing multiline prompts with external text editor (#429)
- Adds a new `Preferences` struct to the config, initially only containing `Editor: bool (default false)`.
  This struct will be serialized to configs once there is a first tea induced change to the config (eg `tea login default <name>` or `tea login add`).
- Use external editor for all multiline prompts if preferred.

We already had a function for starting a texteditor for diff reviews; it does not really make sense to replace it with `survey.Editor`, as there is a big interface mismatch: survey expects strings as inputs, while our diff functions operate on files,

fixes #424

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/429
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-10-14 22:36:08 +08:00
Norwin
5b77345b03 Add tea repo fork (#410)
Adds a new subcommand to fork repos.

To specify the repo to fork, use the `--repo` flag. This feels a bit weird, other tea commands would put this as the first argument.
I decided to follow the flag style, as this is what all other subcommands of `tea repo` do. We might want to reconsider and make the primary subject of such commands an argument, instead of an required flag.. see #430

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-on: https://gitea.com/gitea/tea/pulls/410
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-10-14 15:27:39 +08:00
Norwin
23ce7b351d fix CI release upload: switch to woodpecker/plugin-s3 (#428)
- this fixes the CI release upload issues, as the docker image for this is freshly built (unlike the mostly unmaintained "official" drone plugins), thus containing current CA certs needed for letsencrypt since 2021-09-31.
- woodpecker is a drone-ci fork maintained partially by @6543. it's API compatible with current drone plugins afaik

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/428
Reviewed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-10-10 20:48:51 +08:00
Norwin
375ece06d2 fix lint regression (#425)
On PR #421 CI did not work and it was force merged. Thus we managed to have failing CI on master.. :( sorry

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/425
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-10-05 01:43:06 +08:00
techknowlogick
4ffd994549 Add tea whoami command (#426)
The User print will be used in future for list of users for admin

Co-authored-by: Matti R <matti@mdranta.net>
Reviewed-on: https://gitea.com/gitea/tea/pulls/426
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-committed-by: techknowlogick <techknowlogick@gitea.io>
2021-10-05 01:41:59 +08:00
Norwin
58aaa17e7e Show issue reactions (#421)
```
$ tea issue 230

   #230 issue/pull details: show reactions (open)

  @6543 created 2020-10-22 16:39

  since reactions are utf8 now and most terminals too, we can display them nicely :)

  https://gitea.com/api/v1/repos/gitea/tea/issues/230/reactions

  --------

  1x 🎉  |  1x 👀  |  1x :gitea:  |  1x 👍  |  1x 👎  |  1x 😆  |  1x 😕  |  1x ❤️
```

caveats:
- reactions are not returned as UTF8 (as was claimed in #230), so they need to be parsed. the library I use doesn't (and can't → :gitea:) support all reactions available in gitea
- currently only for issues, as reactions for comments mean an additional API request for each comment..

fixes #230

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/421
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-10-01 16:13:32 +08:00
Norwin
7a05be436c Add more flags to tea repo create (#409)
adds the `--template` and `--trustmodel` flags

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/409
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-29 04:42:51 +08:00
justusbunsi
3cf084cb96 PR listing: add --fields & expose additional fields (#415)
This PR adds the `--fields` flag to `tea pr ls` (#342), and exposes more fields specific to the `PullRequest` type:
```
   --fields value, -f value   Comma-separated list of fields to print.
                              Available values:
                              index,state,author,author-id,url,title,body,mergeable,base,base-commit,head,diff,patch,created,updated,deadline,assignees,milestone,labels,comments
                              (default: "index,title,state,author,milestone,updated,labels")

```

Co-authored-by: justusbunsi <61625851+justusbunsi@users.noreply.github.com>
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/415
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: justusbunsi <justusbunsi@noreply.gitea.io>
Co-committed-by: justusbunsi <justusbunsi@noreply.gitea.io>
2021-09-29 04:36:33 +08:00
Norwin
1e59dee685 Add tea org create <name> (#420)
fixes #287, fixes #363

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/420
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-29 04:32:16 +08:00
justusbunsi
42e423470c Fix notification example (#416)
Co-authored-by: justusbunsi <61625851+justusbunsi@users.noreply.github.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/416
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: justusbunsi <justusbunsi@noreply.gitea.io>
Co-committed-by: justusbunsi <justusbunsi@noreply.gitea.io>
2021-09-29 03:29:48 +08:00
Norwin
555f1ae516 Makefile: add STATIC=true for static PIE builds (#349)
- `make build` + `make install` now support the `STATIC=true` parameter, creating statically linked builds that are also position independent executables
- this requires CGO and a static libc on the build system
- `CGO_ENABLED=0` is set for all make build targets, unless `STATIC=true` is set
- Debug symbols are stripped (`-s -w`) for all make build targets
- Release binaries are built statically by gox (no PIE), as before.

I also took the liberty to declutter the makefile from unused & duplicated variables.

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/349
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-24 00:01:07 +08:00
6543
1c690c5ff8 Changelog v0.8.0 (#404)
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/404
Reviewed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-09-23 03:53:33 +08:00
Norwin
802bdf7dc5 Don't require a body for comment PR reviews (#399)
fixes #372

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/399
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-23 02:18:25 +08:00
Norwin
1731e00ebd Don't skip reading the local repo when --repo specifies a repo slug (#398)
I added this check in #327, but it wasn't needed at all
as the error case it intended to catch where already handled by checking if the path exists.

fixes #378

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/398
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-23 00:12:56 +08:00
Norwin
7b7c7f57be tea pr create: make local repo optional (#393)
this is a partial fix to #378, making the command available outside of a local repo.

new behaviour:
- when run interactively without local repo context, the head repo prompt is not pre-populated
- when run with flags without local repo context, it will complain unless `--head` is specified

refactor:
- pass TeaContext down to task.CreatePull

Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/393
Reviewed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-22 23:48:21 +08:00
Norwin
6e728cf812 Accept more main branch names for login detection (#396)
Also consider `main` and `trunk` as options
to determine a login through its configured remote

fixes #381

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/396
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-14 14:59:11 +08:00
Norwin
808e8b1c5a Correctly match login by ssh host with port (#391)
fixes #380

note: It seems like it was expected that `SSHHost` only contains the host portion.  So this may be breaking (although I don't believe many people used the feature like that with a custom ssh port). I can't think of a good reason to *not* specify the port in that field, including the port seems more intuitive

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/391
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-06 18:52:34 +08:00
Norwin
9201250f74 fix printing issue deadline (#388)
fixes #387

Reviewed-on: https://gitea.com/gitea/tea/pulls/388
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-06 18:45:24 +08:00
Norwin
5b28a05eb7 Implement notification subcommands (#389)
- [x] enhance notification listing
  - add `--states` and `--type` filters
  - toggle per-user or per-repo listing via `--mine` flag
  - print more fields
- [x] add subcommands to mark notifications as read, unread, pinned, unpinned. operates on
  - all notifications matching the `--state` and `--mine` filter flags, or
  - a notification specified by ID.
- [ ] ~~add a `--fields` flag for notifications listing.~~ *not in this PR*
- [ ] ~~interactive mode~~ *not in this PR*. this would go well together with #324

fixes #243, fixes #155

based on initial work in #283 and #386, but opening a new PR for @6543 to review as I changed quite a lot

---

### ⚠️ breaking ⚠️
- `tea notifications --all` has moved to `tea notifications --mine`
- `tea notifications` now only works with the context of a remote repo.
  To run this outside of a local git dir, run either `tea n --mine` or `tea n --repo <my/repo>`

---

Co-authored-by: Karl Heinz Marbaise <kama@soebes.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/389
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Alexey 〒erentyev <axifive@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-09-06 01:11:17 +08:00
Norwin
3fca309f2c Fix adding login without token on private instances (#392)
fixes #365

Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/392
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-08-30 23:19:45 +08:00
Norwin
d6df0a53b5 Update Dependencies (#390)
Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: Norwin <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/390
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-08-30 23:18:50 +08:00
6543
4b9907fb54 Notifications Add State Field (#384)
Reviewed-on: https://gitea.com/gitea/tea/pulls/384
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-08-16 21:23:16 +08:00
6543
ab4e11ae4d Update gitea go-sdk to v0.15.0 (#385)
Update "code.gitea.io/sdk/gitea" to latest release

Reviewed-on: https://gitea.com/gitea/tea/pulls/385
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-08-16 20:46:15 +08:00
nukuta
546fcc16de Handle XDG directories with spaces in autocomplete commands (#383)
On some OSs ([i.e. macOS](https://github.com/adrg/xdg#xdg-base-directory)), XDG directories contain spaces, so we need to wrap the resulting path used in autocomplete sourcing commands in quotation marks.

Co-authored-by: Matthew Daley <mattd@bugfuzz.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/383
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: nukuta <nukuta@noreply.gitea.io>
Co-committed-by: nukuta <nukuta@noreply.gitea.io>
2021-07-24 00:14:23 +08:00
Norwin
0f4f669cf0 Fix parsing of --description for issue/pr create (#371)
The `--description` flag didn't work; regression of #331

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/371
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: KN4CK3R <kn4ck3r@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-07-03 23:23:38 +08:00
Norwin
2bdd72dfff Improve error messages (#370)
fixes #367

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/370
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: KN4CK3R <kn4ck3r@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-07-03 22:39:05 +08:00
techknowlogick
64770a771f rename s3 bucket name (#375)
Reviewed-on: https://gitea.com/gitea/tea/pulls/375
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-committed-by: techknowlogick <techknowlogick@gitea.io>
2021-06-30 04:36:05 +08:00
6543
ebb2c38a0a Return useful error on wrong sshkey path (#374)
close #366

Reviewed-on: https://gitea.com/gitea/tea/pulls/374
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-06-29 15:54:43 +08:00
Norwin
616127cedc Add missing flags (#369)
fixes #368

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/369
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-06-22 22:23:09 +08:00
plgruener
3129e60a73 text editor selection: follow unix defacto standards (#356)
Currently, `tea` only supports the $EDITOR env var to open the user's preferred editor (used for reviewing pull requests).

Standard \*nix practice is, however, to check for $VISUAL first and only then use $EDITOR as fallback.
This is also done by Git itself, see man git-var(1).
(Actually, the order there is $GIT_EDITOR > core.editor > $VISUAL > $EDITOR > vi)

Co-authored-by: plgruener <pl.gruener@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/356
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: plgruener <plgruener@noreply.gitea.io>
Co-committed-by: plgruener <plgruener@noreply.gitea.io>
2021-06-21 20:08:27 +08:00
Norwin
df724b4006 Add tab completion for fish shell (#364)
as title, fixes #361

Handling of fish shell is different in urfave/cli; urfave/cli provides a generator for the shell script needed (probably because the fish `completion` syntax isn't flexible enough to let the application handle the completion at runtime? idk)

This means that the fish completion can become out of sync with the tea binary.
If we want to account for that, on each application run we need to
- check if `~/.config/fish/conf.d/tea_completion.fish` exists; if so
- check if the tea version that wrote it is the currently running version
- if not, rewrite the file.

Not sure this is worth the complexity & cost

It generates a completion that also suggests file names, which looks kinda messy: Didn't find a way around this, but [there may be a way](5bb54ace57/fish.go (L160-L180))
![grafik](/attachments/b08541c9-0f37-4c70-a2e3-1ec9da15a430)

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/364
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-05-24 04:42:21 +08:00
Brahim HAMDOUNI
ffdbdb3d02 Check negative limit command parameter (#358) (#359)
fix #358

Co-authored-by: Brahim Hamdouni <brahim@hamdouni.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/359
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Co-authored-by: Brahim HAMDOUNI <hamdouni@noreply.gitea.io>
Co-committed-by: Brahim HAMDOUNI <hamdouni@noreply.gitea.io>
2021-05-15 22:16:24 +08:00
Norwin
568fde1ce5 Add missing flags to org & labels subcommands (#357)
The `tea orgs` command is an alias to `tea orgs list`, and as such should have the same flags.

fixes #354

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/357
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-05-13 02:32:20 +08:00
Norwin
46945415c9 Enable release builds for darwin/arm64 (#360)
Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/360
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-05-11 08:03:39 +08:00
Tamás Gérczei
195bd2199c contributed container build definition (#350)
as discussed with @noerw on Discord

Co-authored-by: Tamás Gérczei <tamas@gerczei.eu>
Reviewed-on: https://gitea.com/gitea/tea/pulls/350
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Tamás Gérczei <tgerczei@noreply.gitea.io>
Co-committed-by: Tamás Gérczei <tgerczei@noreply.gitea.io>
2021-03-30 19:13:23 +08:00
Norwin
0bf844018c Add tea pr merge (#348)
fixes #343

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/348
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-18 03:56:05 +08:00
Norwin
2319724bb2 Update Changelog (#346)
smal nit's missing

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/346
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-12 20:44:41 +08:00
Norwin
222d0501df Detect markdown line width, resolve relative URLs (#332)
~~this is semi-blocked by https://github.com/charmbracelet/glamour/pull/96, but behaviour isn't really worse than the previous behaviour (most links work, some are still broken)~~

#### testcase for link resolver
```
tea pr 332
tea checkout 332 && make install && tea pr 332
```

- [rel](./332)
- [abs](/gitea/tea/pulls/332)
- [full](https://gitea.com/gitea/tea/pulls/332)

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/332
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-12 20:28:46 +08:00
6543
cb404b53b5 Changelog v0.7.0 (#345)
Reviewed-on: https://gitea.com/gitea/tea/pulls/345
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-03-12 08:41:54 +08:00
Norwin
3abc5a5b42 Allow checking out PRs with deleted head branch (#341)
..by explicitly fetching `refs/pulls/:idx/head` from the base repo.

Sorry, I mixed this with a split-up of `PullCheckout()`. I can try to separate that, if preferred

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/341
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-12 02:16:02 +08:00
Norwin
6f738df4a5 Add more issue / pr creation params (#331)
adds assignees, labels, deadline, milestone params

- [x] add flags to `tea issue create` (this is BREAKING, `-b` moved to `-d` for consistency with pr create)
- [x] add interactive mode to `tea issue create`
- [x] add flags to `tea pr create`
- [x] add interactive mode to `tea pr create`

fixes #171, fixes #303

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/331
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-08 19:48:03 +08:00
6543
d22b314701 Introduce workaround for missing pull head sha (#340)
fix #318

test with `tea pr 58`

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/340
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-03-08 03:45:50 +08:00
6543
786c713ff5 [CI] use golang v1.16 (#339)
Reviewed-on: https://gitea.com/gitea/tea/pulls/339
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-03-05 20:37:50 +08:00
Norwin
d474883e90 don't push before creating a pull (#334)
Not sure if this is the best way, but it's the simplest way to fix #333.
Everything else is overly complex due to a chicken-egg problem:
Knowing which remote / branch to push involves requires prompting the user,
which requires to have a upstream branch pushed to detect default values.

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/334
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-05 18:27:09 +08:00
6543
0d98cbd657 Update Vendors (#337)
* update & migrate gitea sdk (Fix Delete Tag Issue)
* upgraded github.com/AlecAivazis/survey v2.2.7 => v2.2.8
* upgraded github.com/adrg/xdg v0.2.3 => v0.3.1
* upgraded github.com/araddon/dateparse
* upgraded github.com/olekukonko/tablewriter v0.0.4 => v0.0.5
* upgraded gopkg.in/yaml.v2 v2.3.0 => v2.4.0

Reviewed-on: https://gitea.com/gitea/tea/pulls/337
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-committed-by: 6543 <6543@obermui.de>
2021-03-05 18:06:25 +08:00
Norwin
15c4edba1a Don't exit if we can't find a local repo with a remote matching to a login (#336)
This enables to run commands that need minimal context (i.e. `tea n --all`) to run anywhere.

fixes #329

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/336
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-05 16:56:15 +08:00
Norwin
e96cfdbbe7 tea pr checkout: dont create local branches (#314)
This avoids creation of local branches, to avoid cluttering the local repo:
- if the commit already exists on the tip of a local branch, check that one out
- otherwise check out the remote tracking branch (`refs/remotes/<remote>/<head>`), and suggest what to do if you want to make changes.

I'm not certain this behaviour is actually better, I suggest leaving this open for a while for people to try out the new behaviour:
```
tea pr checkout 314
make install
```

fixes #293

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/314
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-02 21:50:11 +08:00
Norwin
3c1efd33e2 InitCommand() robustness (#327)
fixes #320

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/327
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-01 06:29:26 +08:00
Norwin
9c8321f2e0 tea comment: handle piped stdin (#322)
fixes #321

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/322
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Norwin <noerw@noreply.gitea.io>
Co-committed-by: Norwin <noerw@noreply.gitea.io>
2021-03-01 01:47:36 +08:00
Norwin
b5c670ebf8 Improve tea time (#319)
better docs

add --mine flag

hm, is there a better name? 🤔

do time filtering serverside

make printed fields dynamic

add --fields to tea times ls

code review

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/319
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-23 12:58:36 +08:00
Norwin
95ef061711 Update dependencies (#316)
update xdg

update survey

update go-sdk

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/316
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-22 01:11:08 +08:00
Norwin
32b7b771cc Add tea comment and show comments of issues/pulls (#313)
show comments of PR

TODO: there needs to be a way to force running non-interactively

add `tea comment` to post a comment

add --comments flag, prompt only if necessary

don't prompt if --comments is provided, or output is piped

show comments for issues, add --comments flag

tea comment: print resulting comment

Merge branch 'master' into issue-172-comments

remove debug print statement

unrelated, but better than opening another PR for this ;)

Merge remote-tracking branch 'upstream/master' into issue-172-comments

ret err

fix lint

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/313
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-22 00:07:35 +08:00
Norwin
9efee7bf99 Add tea issues --fields, allow printing labels (#312)
generalize list printing with dynamic fields

refactor print.IssuesList to use tableFromItems()

preparatory refactor

print.IssuesList: allow printing labels

move formatters to formatters.go

expose more printable fields on issue

add generic flags.FieldsFlag

add fields flag to tea issues, tea ms issues

validate provided fields

add strict username, or formatted user fields

change default fields

tea issues -> replace updated with labels
tea ms issues -> replace author with labels, reorder

Validate provided fields

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/312
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-21 23:41:07 +08:00
Norwin
8bb5c15745 Add commands for reviews (#315)
add interactive `tea pr review`

it's amazingly simple

vendor gitea.com/noerw/unidiff-comments

add `tea pr lgtm|reject` shorthands

vendor slimmed down diff parser

review diff: default to true

if users want a shortcut, they can use lgtm or reject subcmds

`tea pr approve`: accept optional comment

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/315
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-21 23:22:22 +08:00
Norwin
43a58bdba1 Proper help text & new README structure (#311)
add cli.AppHelpTemplate for customization

customize tea help view

tea --version : improve parseability

Rework README to include tea help output

It's an antipattern to have different help texts aimed at the same
users. So now that we have a good cli help text, lets use it here.
This eases maintenance, and at the same time gives an honest impression
on what we have to offer, while also encouraging to improve the internal
help text in the future.

I feel a bit sad for the GIF, but it was becoming outdated anyway..

group commands by category

add new demo gif

shows the (probably) most useful workflow

readme improvement

Merge branch 'master' into improve-app-help

code review

Merge branch 'master' into improve-app-help

restructure installation section

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/311
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-21 21:37:20 +08:00
Martin Reboredo
43e9943757 Add interactive mode for tea milestone create (#310)
Implement interactive milestone creation

Return fmt.Errorf when title is empty

Incorporate deadline functionality

Use dateparse and cleanup CreateMilestone task

Signed-off-by: Martin Reboredo <yakoyoku@gmail.com>
Co-authored-by: Martin Reboredo <yakoyoku@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/310
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Martin Reboredo <yakoyakoyokuyoku@noreply.gitea.io>
Co-Committed-By: Martin Reboredo <yakoyakoyokuyoku@noreply.gitea.io>
2020-12-18 02:50:07 +08:00
Norwin
8b588f5313 make PR workflow helpers more robust (#300)
improve handling of remote deleted branches

split git.TeaDeleteBranch

only delete remote branch if we have permission

add missing err check

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/300
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-17 22:00:16 +08:00
Martin Reboredo
a2e8b47c57 Implement PR closing and reopening (#304)
Implement pull request closing/reopening

Signed-off-by: Martin Reboredo <yakoyoku@gmail.com>

Correct year and `pull` description

Apply changes from #291

Return fmt.Errorf instead of log.Fatal if no pull index was supplied

Co-authored-by: Martin Reboredo <yakoyoku@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/304
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: appleboy <appleboy.tw@gmail.com>
Co-Authored-By: Martin Reboredo <yakoyakoyokuyoku@noreply.gitea.io>
Co-Committed-By: Martin Reboredo <yakoyakoyokuyoku@noreply.gitea.io>
2020-12-17 06:47:12 +08:00
Norwin
83b73ce78e Show PR CI status (#306)
fix layout of pr reviews

show PR CI status

put conflict info in status list

remove line

show merged state

deduplicate reviews by user

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/306
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-17 01:16:50 +08:00
Norwin
782a6318f3 Add more command shorthands (#307)
add more command aliases

breaking: s/notif/n

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/307
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-17 00:47:40 +08:00
Norwin
a948fd7e10 Refactor error handling (#308)
use fmt instead of log

log.Fatal -> return err

set non-zero exit code on error

print to default err log

cleanup

fix vet

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/308
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-17 00:18:10 +08:00
Norwin
287df8a715 Add command to install shell completion (#309)
add autocompletion files to contrib/

curl -o contrib/autocomplete.zsh https://raw.githubusercontent.com/urfave/cli/master/autocomplete/zsh_autocomplete
curl -o contrib/autocomplete.sh https://raw.githubusercontent.com/urfave/cli/master/autocomplete/bash_autocomplete
add powershell

add `tea meta autocomplete`

closes #86

update docs

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/309
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-17 00:01:59 +08:00
Norwin
dc67630b64 replace flag globals, require context for commands (#291)
introduce TeaContext

clean up InitCommand

move GetListOptions to TeaContext

ensure context for each command

so we fail early with a good error message instead of "Error: 404" etc

make linter happy

Merge branch 'master' into refactor-global-flags

move TeaContext & InitCommand to modules/context

Merge branch 'master' into refactor-global-flags

CI.restart()

Merge branch 'master' into refactor-global-flags

Merge branch 'master' into refactor-global-flags

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/291
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-16 01:38:22 +08:00
Norwin
e5cdad554e Add feature comparison chart between forge CLIs (#294)
WIP: add comparison

Merge branch 'master' into issue-194-comparison

move file

hint in readme

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/294
Reviewed-by: 6543 <6543@obermui.de>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
2020-12-15 12:59:49 +08:00
Martin Reboredo
b9f5ba0702 Add interactive mode for tea issue create (#302)
Implement interactive issue creation

Comment PromptRepoSlug

Move PromptRepoSlug to the right place

Hide promptRepoSlug

Signed-off-by: Martin Reboredo <yakoyoku@gmail.com>
Co-authored-by: Martin Reboredo <yakoyoku@gmail.com>
Reviewed-on: https://gitea.com/gitea/tea/pulls/302
Reviewed-by: Norwin <noerw@noreply.gitea.io>
Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Martin Reboredo <yakoyakoyokuyoku@noreply.gitea.io>
Co-Committed-By: Martin Reboredo <yakoyakoyokuyoku@noreply.gitea.io>
2020-12-15 04:05:31 +08:00
1729 changed files with 9729 additions and 407170 deletions

View File

@ -0,0 +1,20 @@
{
"name": "Tea DevContainer",
"image": "mcr.microsoft.com/devcontainers/go:1.22-bullseye",
"features": {
"ghcr.io/devcontainers/features/git-lfs:1.2.2": {}
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"editorconfig.editorconfig",
"golang.go",
"stylelint.vscode-stylelint",
"DavidAnson.vscode-markdownlint",
"ms-azuretools.vscode-docker",
"GitHub.vscode-pull-request-github"
]
}
}
}

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
Dockerfile
tea

View File

@ -1,189 +0,0 @@
---
kind: pipeline
name: default
platform:
os: linux
arch: amd64
steps:
- name: build
pull: always
image: golang:1.15
environment:
GOPROXY: https://goproxy.cn
commands:
- make clean
- make vet
- make lint
- make fmt-check
- make misspell-check
- make test-vendor
- make build
when:
event:
- push
- tag
- pull_request
- name: unit-test
image: golang:1.15
commands:
- make unit-test-coverage
settings:
group: test
when:
branch:
- master
event:
- push
- pull_request
- name: release-test
image: golang:1.15
commands:
- make test
settings:
group: test
when:
branch:
- "release/*"
event:
- push
- pull_request
- name: tag-test
pull: always
image: golang:1.15
commands:
- make test
settings:
group: test
when:
event:
- tag
- name: static
image: golang:1.15
environment:
GOPROXY: https://goproxy.cn
commands:
- export PATH=$PATH:$GOPATH/bin
- make release
when:
event:
- push
- tag
- name: gpg-sign
pull: always
image: plugins/gpgsign:1
settings:
detach_sign: true
excludes:
- "dist/release/*.sha256"
files:
- "dist/release/*"
environment:
GPGSIGN_KEY:
from_secret: gpgsign_key
GPGSIGN_PASSPHRASE:
from_secret: gpgsign_passphrase
when:
event:
- push
- tag
- name: tag-release
pull: always
image: plugins/s3:1
settings:
acl: public-read
bucket: releases
endpoint: https://storage.gitea.io
path_style: true
source: "dist/release/*"
strip_prefix: dist/release/
target: "/tea/${DRONE_TAG##v}"
environment:
AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id
AWS_SECRET_ACCESS_KEY:
from_secret: aws_secret_access_key
when:
event:
- tag
- name: release-branch-release
pull: always
image: plugins/s3:1
settings:
acl: public-read
bucket: releases
endpoint: https://storage.gitea.io
path_style: true
source: "dist/release/*"
strip_prefix: dist/release/
target: "/tea/${DRONE_BRANCH##release/v}"
environment:
AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id
AWS_SECRET_ACCESS_KEY:
from_secret: aws_secret_access_key
when:
branch:
- "release/*"
event:
- push
- name: release
pull: always
image: plugins/s3:1
settings:
acl: public-read
bucket: releases
endpoint: https://storage.gitea.io
path_style: true
source: "dist/release/*"
strip_prefix: dist/release/
target: /tea/master
environment:
AWS_ACCESS_KEY_ID:
from_secret: aws_access_key_id
AWS_SECRET_ACCESS_KEY:
from_secret: aws_secret_access_key
when:
branch:
- master
event:
- push
- name: gitea
pull: always
image: plugins/gitea-release:1
settings:
files:
- "dist/release/*"
base_url: https://gitea.com
api_key:
from_secret: gitea_token
when:
event:
- tag
- name: discord
pull: always
image: appleboy/drone-discord:1.0.0
environment:
DISCORD_WEBHOOK_ID:
from_secret: discord_webhook_id
DISCORD_WEBHOOK_TOKEN:
from_secret: discord_webhook_token
when:
event:
- push
- tag
- pull_request
status:
- changed
- failure

View File

@ -0,0 +1,30 @@
---
name: "Bug Report"
about: "Use this template when reporting a bug, so you don't forget important information we'd ask for later."
title: "Bug: "
labels:
- kind/bug
---
### describe your environment
- tea version used (`tea -v`):
- [ ] 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:
- I make use of...
- [ ] non-standard default branch names (no `main`,`master`, or `trunk`)
- [ ] .ssh/config or .gitconfig host aliases in my git remotes
- [ ] ssh_agent or similar
- [ ] non-standard ports for gitea and/or ssh
- [ ] something else that's likely to interact badly with tea: ...
Please provide the output of `git remote -v` (if the issue is related to tea not finding resources on Gitea):
```
```
### describe the issue (observed vs expected behaviour)

View File

@ -0,0 +1,75 @@
name: goreleaser
on:
push:
branches: [ main ]
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: import gpg
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPGSIGN_KEY }}
passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }}
- name: goreleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
version: "~> v1"
args: release --nightly
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
S3_REGION: ${{ secrets.AWS_REGION }}
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPGSIGN_PASSPHRASE: ${{ secrets.GPGSIGN_PASSPHRASE }}
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-image:
runs-on: ubuntu-latest
env:
DOCKER_ORG: gitea
DOCKER_LATEST: nightly
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # all history for all branches and tags
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker BuildX
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v6
env:
ACTIONS_RUNTIME_TOKEN: '' # See https://gitea.com/gitea/act_runner/issues/119
with:
context: .
file: ./Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
gitea/tea:latest

View File

@ -0,0 +1,42 @@
name: goreleaser
on:
push:
tags:
- '*'
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- run: git fetch --force --tags
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: import gpg
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPGSIGN_KEY }}
passphrase: ${{ secrets.GPGSIGN_PASSPHRASE }}
fingerprint: CC64B1DB67ABBEECAB24B6455FC346329753F4B0
- name: goreleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser-pro
version: "~> v1"
args: release
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
S3_REGION: ${{ secrets.AWS_REGION }}
S3_BUCKET: ${{ secrets.AWS_BUCKET }}
GORELEASER_FORCE_TOKEN: 'gitea'
GPGSIGN_PASSPHRASE: ${{ secrets.GPGSIGN_PASSPHRASE }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITEA_TOKEN: ${{ secrets.RELEASE_TOKEN }}

View File

@ -0,0 +1,30 @@
name: check-and-test
on:
- pull_request
jobs:
check-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: lint and build
run: |
make clean
make vet
make lint
make fmt-check
make misspell-check
make docs-check
make build
env:
GOPROXY: https://goproxy.io,direct
- name: test and coverage
run: |
make test
make unit-test-coverage
env:
GOPROXY: https://goproxy.io,direct

8
.gitignore vendored
View File

@ -1,6 +1,14 @@
tea
/gitea-vet
/gitea-vet.exe
.idea/
.history/
dist/
.vscode/
vendor/
coverage.out
dist/

12
.goreleaser.checksum.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
if [ -z "$1" ]; then
echo "usage: $0 <path>"
exit 1
fi
SUM=$(shasum -a 256 "$1" | cut -d' ' -f1)
BASENAME=$(basename "$1")
echo -n "${SUM} ${BASENAME}" > "$1".sha256

124
.goreleaser.yaml Normal file
View File

@ -0,0 +1,124 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
- freebsd
goarch:
- amd64
- arm
- arm64
goarm:
- "5"
- "6"
- "7"
ignore:
- goos: darwin
goarch: arm
- goos: darwin
goarch: ppc64le
- goos: darwin
goarch: s390x
- goos: windows
goarch: ppc64le
- goos: windows
goarch: s390x
- goos: windows
goarch: arm
goarm: "5"
- goos: windows
goarch: arm
goarm: "6"
- goos: windows
goarch: arm
goarm: "7"
- goos: windows
goarch: arm64
- goos: freebsd
goarch: ppc64le
- goos: freebsd
goarch: s390x
- goos: freebsd
goarch: arm
goarm: "5"
- goos: freebsd
goarch: arm
goarm: "6"
- goos: freebsd
goarch: arm
goarm: "7"
- goos: freebsd
goarch: arm64
flags:
- -trimpath
ldflags:
- -s -w -X main.Version={{ .Version }}
binary: >-
{{ .ProjectName }}-
{{- .Version }}-
{{- .Os }}-
{{- if eq .Arch "amd64" }}amd64
{{- else if eq .Arch "amd64_v1" }}amd64
{{- else if eq .Arch "386" }}386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}-{{ .Arm }}{{ end }}
no_unique_dist_dir: true
hooks:
post:
- cmd: xz -k -9 {{ .Path }}
dir: ./dist/
- cmd: sh .goreleaser.checksum.sh {{ .Path }}
- cmd: sh .goreleaser.checksum.sh {{ .Path }}.xz
blobs:
-
provider: s3
bucket: "{{ .Env.S3_BUCKET }}"
region: "{{ .Env.S3_REGION }}"
folder: "tea/{{.Version}}"
extra_files:
- glob: ./**.xz
- glob: ./**.sha256
archives:
- format: binary
name_template: "{{ .Binary }}"
allow_different_binary_count: true
checksum:
name_template: 'checksums.txt'
extra_files:
- glob: ./**.xz
force_token: gitea
signs:
-
signature: "${artifact}.sig"
artifacts: checksum
stdin: '{{ .Env.GPGSIGN_PASSPHRASE }}'
args: ["--batch", "-u", "{{ .Env.GPG_FINGERPRINT }}", "--output", "${signature}", "--detach-sign", "${artifact}"]
snapshot:
name_template: "{{ .Branch }}-devel"
nightly:
name_template: "{{ .Branch }}"
gitea_urls:
api: https://gitea.com/api/v1
download: https://gitea.com
release:
extra_files:
- glob: ./**.xz
- glob: ./**.xz.sha256
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

View File

@ -16,7 +16,6 @@ warningCode = 1
[rule.increment-decrement]
[rule.var-naming]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
[rule.receiver-naming]
[rule.time-naming]

View File

@ -1,5 +1,107 @@
# Changelog
## [v0.9.1](https://gitea.com/gitea/tea/releases/tag/v0.9.1) - 2023-02-15
* BUGFIXES
* Print pull dont crash if it has TeamReviewRequests (#517)
## [v0.9.0](https://gitea.com/gitea/tea/releases/tag/v0.9.0) - 2022-09-13
* BREAKING
* Rename master branch to main (#495)
* Return RFC3339 UTC timestamps for machine-readable output (#470)
* FEATURES
* Allow editing multiline prompts with external text editor (#429)
* Add `tea admin user list` (#427)
* Add `tea whoami` command (#426)
* Add `tea org create <name>` (#420)
* Add `tea clone` (#411)
* Add `tea repo fork` (#410)
* Add `tea repo create-from-template` (#408)
* BUGFIXES
* Fetch all items where needed. (#475)
* Fix running in repos without remote (#472)
* Add TSV to machine-readable formats (#467)
* Fix create milestone with deadline bug (#462)
* Fix resolving of URLs in markdown (#401)
* ENHANCEMENTS
* Don't emit ANSI sequences when not emitting to TTY for markdown (#491)
* Show more version info (#486)
* Add preference `flag_defaults.remote`, refactor (#466)
* Add `--fields` to notification & milestone listings (#422)
* PR listing: add --fields & expose additional fields (#415)
* Add more flags to `tea repo create` (#409)
* Implement more issue filters (#400)
* MISC
* Simplify build & update installation instructions (#437)
* Clarify command descriptions when no arguments are taken (#496)
* Improve Documentation (#433)
* Use golang v1.18 and drop vendor folder (#478)
* Correct spelling of "wether" to "whether" in usage output (#453)
## [v0.8.0](https://gitea.com/gitea/tea/releases/tag/v0.8.0) - 2021-09-22
* BREAKING
* `tea notifications --all` has moved to `tea notifications --mine` (#389)
* `tea notifications` now only works with the context of a remote repo. (#389)
To run this outside of a local git dir, run either tea n `--mine` or `tea n --repo <my/repo>`
* FEATURES
* Add `tea pr merge` (#348)
* BUGFIXES
* Don't skip reading the local repo when `--repo` specifies a repo slug (#398)
* Fix adding login without token on private instances (#392)
* Correctly match login by ssh host with port (#391)
* Fix printing issue deadline (#388)
* Return useful error on wrong sshkey path (#374)
* Fix parsing of `--description` for issue/pr create (#371)
* Add missing flags (#369)
* Check negative limit command parameter (#358) (#359)
* Add missing flags to org & labels subcommands (#357)
* ENHANCEMENTS
* Don't require a body for comment PR reviews (#399)
* Accept more main branch names for login detection (#396)
* Make local repo optional for `tea pr create`(#393)
* Notifications Add State Field (#384)
* Improve error messages (#370)
* Add tab completion for fish shell (#364)
* Text editor selection: follow unix defacto standards (#356)
* MISC
* Update Dependencies (#390)
## [v0.7.1](https://gitea.com/gitea/tea/releases/tag/v0.7.1) - 2021-08-27
* BUILD
* Enable release builds for darwin/arm64 (#360)
## [v0.7.0](https://gitea.com/gitea/tea/releases/tag/v0.7.0) - 2021-03-12
* BREAKING
* `tea issue create`: move `-b` flag to `-d` (#331)
* Drop `tea notif` shorthand in favor of `tea n` (#307)
* FEATURES
* Add commands for reviews (#315)
* Add `tea comment` and show comments of issues/pulls (#313)
* Add interactive mode for `tea milestone create` (#310)
* Add command to install shell completion (#309)
* Implement PR closing and reopening (#304)
* Add interactive mode for `tea issue create` (#302)
* BUGFIXES
* Introduce workaround for missing pull head sha (#340)
* Don't exit if we can't find a local repo with a remote matching to a login (#336)
* Don't push before creating a pull (#334)
* InitCommand() robustness (#327)
* `tea comment`: handle piped stdin (#322)
* ENHANCEMENTS
* Allow checking out PRs with deleted head branch (#341)
* Markdown renderer: detect terminal width, resolve relative URLs (#332)
* Add more issue / pr creation parameters (#331)
* Improve `tea time` (#319)
* `tea pr checkout`: dont create local branches (#314)
* Add `tea issues --fields`, allow printing labels (#312)
* Add more command shorthands (#307)
* Show PR CI status (#306)
* Make PR workflow helpers more robust (#300)
## [v0.6.0](https://gitea.com/gitea/tea/releases/tag/v0.6.0) - 2020-12-11
* BREAKING

View File

@ -7,7 +7,6 @@
- [Bug reports](#bug-reports)
- [Discuss your design](#discuss-your-design)
- [Testing redux](#testing-redux)
- [Vendoring](#vendoring)
- [Code review](#code-review)
- [Styleguide](#styleguide)
- [Sign-off your work](#sign-off-your-work)
@ -57,27 +56,13 @@ high-level discussions.
## Testing redux
Before sending code out for review, run all the test by execting: `make test`
Since TEA is an cli tool it should be obvious to test your feature localy first.
## Vendoring
We keep a cached copy of dependencies within the `vendor/` directory,
managing updates via [dep](https://github.com/golang/dep).
Pull requests should only include `vendor/` updates if they are part of
the same change, be it a bugfix or a feature addition.
The `vendor/` update needs to be justified as part of the PR description,
and must be verified by the reviewers and/or merger to always reference
an existing upstream commit.
You can find more information on how to get started with it on the [dep project website](https://golang.github.io/dep/docs/introduction.html).
Before sending code out for review, run all the test by executing: `make test`
Since TEA is an cli tool it should be obvious to test your feature locally first.
## Code review
Changes to TEA must be reviewed before they are accepted—no matter who
makes the change, even if they are an owner or a maintainer. We use Giteas's
makes the change, even if they are an owner or a maintainer. We use Gitea's
pull request & review workflow to do that. Gitea ensure every PR is reviewed by at least 2 maintainers.
Please try to make your pull request easy to review for us. And, please read
@ -118,8 +103,8 @@ Some of the key points:
- Always make sure that the help texts are properly set, and as concise as possible.
### Internal Module Structure
- `cmd`: only contains comand/flag options for `urfave/cli`
- subcomands are in a subpackage named after its parent comand
- `cmd`: only contains command/flag options for `urfave/cli`
- subcommands are in a subpackage named after its parent command
- `modules/task`: contain func for doing something with gitea
(e.g. create token by user/passwd)
- `modules/print`: contain all functions that print to stdout
@ -175,7 +160,7 @@ maintainers](MAINTAINERS). Every PR **MUST** be reviewed by at least
two maintainers (or owners) before it can get merged. A maintainer
should be a contributor of Gitea (or Gogs) and contributed at least
4 accepted PRs. A contributor should apply as a maintainer in the
[Discord](https://discord.gg/NsatcWJ) #develop channel. The owners
[Discord](https://discord.gg/Gitea) #develop channel. The owners
or the team maintainers may invite the contributor. A maintainer
should spend some time on code reviews. If a maintainer has no
time to do that, they should apply to leave the maintainers team
@ -208,7 +193,7 @@ https://help.github.com/articles/securing-your-account-with-two-factor-authentic
After the election, the new owners should proactively agree
with our [CONTRIBUTING](CONTRIBUTING.md) requirements in the
[Discord](https://discord.gg/NsatcWJ) #general channel. Below are the
[Discord](https://discord.gg/Gitea) #general channel. Below are the
words to speak:
```
@ -236,8 +221,8 @@ Code that you contribute should use the standard copyright header:
```
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
```
Files in the repository contain copyright from the year they are added

10
Dockerfile Normal file
View File

@ -0,0 +1,10 @@
FROM cgr.dev/chainguard/go:latest AS build
COPY . /build/
WORKDIR /build
RUN make build
FROM cgr.dev/chainguard/static:latest
COPY --from=build /build/tea /tea
VOLUME [ "/app" ]
ENV HOME="/app"
ENTRYPOINT ["/tea"]

63
FEATURE-COMPARISON.md Normal file
View File

@ -0,0 +1,63 @@
# comparing git forge commandline interfaces
[tea]: https://gitea.com/gitea/tea
[sip]: https://gitea.com/jolheiser/sip
[gitlab]: https://github.com/makkes/gitlab-cli
[glab]: https://github.com/profclems/glab
[gh]: https://cli.github.com
last update: 2020-12-11
## general
/ | [tea][tea] | [sip][sip] | [gitlab][gitlab] | [gh][gh]
-----------------------|:-----:|:-----:|:-----:|:-----:
forge|gitea|gitea|gitlab|github
official forge support|✓|✘|✘|✓
dev status|adding features|maintenance||
platform|any|any|any|any
## philosophy
/ | [tea][tea] | [sip][sip] | [gitlab][gitlab] | [gh][gh]
-----------------------|:-----:|:-----:|:-----:|:-----:
aims to replace git cli|✘|||✓
works with decentralization in mind|✓|✓|✓|✘
per-repo setup needed|✘||✓|✘
workflow helpers|✓|||
interactive mode |[(✓)](https://gitea.com/gitea/tea/issues?type=all&state=open&labels=&milestone=0&assignee=0&q=interactive)|✘| |✓
programmatic mode|✓|||✓
machine readable output|✓|||
follows XDG spec|✓|||
## features
/ | [tea][tea] | [sip][sip] | [gitlab][gitlab] | [gh][gh]
-----------------------|:-----:|:-----:|:-----:|:-----:
open web UI|✓|||
search repos|✓|||
search issues|✘|✓||
textual item search filter syntax|✘|✓||
CRUD repos|[(✓)](https://gitea.com/gitea/tea/issues/239)|||
CRUD issues|[(✓)](https://gitea.com/gitea/tea/issues/229)|||
CRUD milestones|[(✓)](https://gitea.com/gitea/tea/issues/246)|||
CRUD releases|✓|||
CRUD labels|✓|||
CRUD PRs|✓|||
CRUD time tracking|✓|||x
CRUD orgs|[(✓)](https://gitea.com/gitea/tea/issues/287)|||
create PRs from local repo|✓|||
create PRs from remote repo|✓|||
code review|[u](https://gitea.com/gitea/tea/issues/131)|||
merge PRs||||
read comments|[u](https://gitea.com/gitea/tea/issues/172)|||
post comments||||
manage CI|✘|✘|✓|
manage notifications|[(✓)]()|||
administration|[u](https://gitea.com/gitea/tea/issues/161)|✘||✘
markdown rendering|✓|||✓
issue import/export|[u](https://gitea.com/gitea/tea/issues/132)|||
checkout PRs|✓|||
- ✓: supported
- (✓): partial support
- u: upcoming
- ✘: not supported
- ?: unknown

View File

@ -1,5 +1,4 @@
Copyright (c) 2016 The Gitea Authors
Copyright (c) 2015 The Gogs Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

140
Makefile
View File

@ -1,31 +1,12 @@
DIST := dist
IMPORT := code.gitea.io/tea
export GO111MODULE=on
GO ?= go
SED_INPLACE := sed -i
SHASUM ?= shasum -a 256
export PATH := $($(GO) env GOPATH)/bin:$(PATH)
ifeq ($(OS), Windows_NT)
EXECUTABLE := tea.exe
else
EXECUTABLE := tea
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SED_INPLACE := sed -i ''
endif
endif
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*" ! -path "*/bindata.go")
GOFILES := $(shell find . -name "*.go" -type f ! -path "*/bindata.go")
GOFMT ?= gofmt -s
GOFLAGS := -i -v
EXTRA_GOFLAGS ?=
MAKE_VERSION := $(shell make -v | head -n 1)
ifneq ($(DRONE_TAG),)
VERSION ?= $(subst v,,$(DRONE_TAG))
TEA_VERSION ?= $(VERSION)
@ -33,33 +14,37 @@ else
ifneq ($(DRONE_BRANCH),)
VERSION ?= $(subst release/v,,$(DRONE_BRANCH))
else
VERSION ?= master
VERSION ?= main
endif
TEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
endif
LDFLAGS := -X "main.Version=$(TEA_VERSION)" -X "main.Tags=$(TAGS)"
PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/)
SOURCES ?= $(shell find . -name "*.go" -type f)
TEA_VERSION_TAG ?= $(shell sed 's/+/_/' <<< $(TEA_VERSION))
TAGS ?=
SDK ?= $(shell $(GO) list -f '{{.Version}}' -m code.gitea.io/sdk/gitea)
LDFLAGS := -X "main.Version=$(TEA_VERSION)" -X "main.Tags=$(TAGS)" -X "main.SDK=$(SDK)" -s -w
# override to allow passing additional goflags via make CLI
override GOFLAGS := $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)'
PACKAGES ?= $(shell $(GO) list ./...)
SOURCES ?= $(shell find . -name "*.go" -type f)
# OS specific vars.
ifeq ($(OS), Windows_NT)
EXECUTABLE := tea.exe
VET_TOOL := gitea-vet.exe
else
EXECUTABLE := tea
VET_TOOL := gitea-vet
endif
# $(call strip-suffix,filename)
strip-suffix = $(firstword $(subst ., ,$(1)))
.PHONY: all
all: build
.PHONY: clean
clean:
$(GO) clean -mod=vendor -i ./...
$(GO) clean -i ./...
rm -rf $(EXECUTABLE) $(DIST)
.PHONY: fmt
@ -69,31 +54,22 @@ fmt:
.PHONY: vet
vet:
# Default vet
$(GO) vet -mod=vendor $(PACKAGES)
$(GO) vet $(PACKAGES)
# Custom vet
$(GO) build -mod=vendor code.gitea.io/gitea-vet
$(GO) vet -vettool=gitea-vet $(PACKAGES)
$(GO) build code.gitea.io/gitea-vet
$(GO) vet -vettool=$(VET_TOOL) $(PACKAGES)
.PHONY: lint
lint:
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
cd /tmp && $(GO) get -u github.com/mgechev/revive; \
fi
revive -config .revive.toml -exclude=./vendor/... ./... || exit 1
lint: install-lint-tools
$(GO) run github.com/mgechev/revive@v1.3.2 -config .revive.toml ./... || exit 1
.PHONY: misspell-check
misspell-check:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
cd /tmp && $(GO) get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -error -i unknwon,destory $(GOFILES)
misspell-check: install-lint-tools
$(GO) run github.com/client9/misspell/cmd/misspell@latest -error -i unknwon,destory $(GOFILES)
.PHONY: misspell
misspell:
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
cd /tmp && $(GO) get -u github.com/client9/misspell/cmd/misspell; \
fi
misspell -w -i unknwon $(GOFILES)
misspell: install-lint-tools
$(GO) run github.com/client9/misspell/cmd/misspell@latest -w -i unknwon $(GOFILES)
.PHONY: fmt-check
fmt-check:
@ -105,61 +81,53 @@ fmt-check:
exit 1; \
fi;
.PHONY: docs
docs:
$(GO) run . docs --out docs/CLI.md
.PHONY: docs-check
docs-check:
@DIFF=$$($(GO) run . docs | diff docs/CLI.md -); \
if [ -n "$$DIFF" ]; then \
echo "Please run 'make docs' and commit the result:"; \
echo "$$DIFF"; \
exit 1; \
fi;
.PHONY: test
test:
$(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
$(GO) test -tags='sqlite sqlite_unlock_notify' $(PACKAGES)
.PHONY: unit-test-coverage
unit-test-coverage:
$(GO) test -mod=vendor -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
$(GO) test -tags='sqlite sqlite_unlock_notify' -cover -coverprofile coverage.out $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1
.PHONY: vendor
vendor:
$(GO) mod tidy && $(GO) mod vendor
.PHONY: test-vendor
test-vendor: vendor
@diff=$$(git diff vendor/); \
if [ -n "$$diff" ]; then \
echo "Please run 'make vendor' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;
.PHONY: tidy
tidy:
$(GO) mod tidy
.PHONY: check
check: test
.PHONY: install
install: $(wildcard *.go)
$(GO) install -mod=vendor -v -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)'
install: $(SOURCES)
@echo "installing to $(shell $(GO) env GOPATH)/bin/$(EXECUTABLE)"
$(GO) install -v $(BUILDMODE) $(GOFLAGS)
.PHONY: build
build: $(EXECUTABLE)
$(EXECUTABLE): $(SOURCES)
$(GO) build -mod=vendor $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
$(GO) build $(BUILDMODE) $(GOFLAGS) -o $@
.PHONY: release
release: release-dirs release-os release-compress release-check
.PHONY: build-image
build-image:
docker build --build-arg VERSION=$(TEA_VERSION) -t gitea/tea:$(TEA_VERSION_TAG) .
.PHONY: release-dirs
release-dirs:
mkdir -p $(DIST)/binaries $(DIST)/release
.PHONY: release-os
release-os:
@hash gox > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
cd /tmp && $(GO) get -u github.com/mitchellh/gox; \
install-lint-tools:
@hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) install github.com/mgechev/revive@v1.3.2; \
fi
CGO_ENABLED=0 gox -verbose -cgo=false -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -osarch='!darwin/386 !darwin/arm64 !darwin/arm' -os="windows linux darwin" -arch="386 amd64 arm arm64" -output="$(DIST)/release/tea-$(VERSION)-{{.OS}}-{{.Arch}}"
.PHONY: release-compress
release-compress:
@hash gxz > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
GO111MODULE=off $(GO) get -u github.com/ulikunitz/xz/cmd/gxz; \
@hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \
$(GO) install github.com/client9/misspell/cmd/misspell@latest; \
fi
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && gxz -k -9 $${file}; done;
.PHONY: release-check
release-check:
cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done;

164
README.md
View File

@ -1,74 +1,127 @@
# <img alt='' src='https://gitea.com/repo-avatars/550-80a3a8c2ab0e2c2d69f296b7f8582485' height="40"/> *T E A*
# <img alt='tea logo' src='https://gitea.com/repo-avatars/550-80a3a8c2ab0e2c2d69f296b7f8582485' height="40"/> *T E A*
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Release](https://raster.shields.io/badge/dynamic/json.svg?label=release&url=https://gitea.com/api/v1/repos/gitea/tea/releases&query=$[0].tag_name)](https://gitea.com/gitea/tea/releases) [![Build Status](https://drone.gitea.com/api/badges/gitea/tea/status.svg)](https://drone.gitea.com/gitea/tea) [![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea) [![Go Report Card](https://goreportcard.com/badge/code.gitea.io/tea)](https://goreportcard.com/report/code.gitea.io/tea) [![GoDoc](https://godoc.org/code.gitea.io/tea?status.svg)](https://godoc.org/code.gitea.io/tea)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Release](https://raster.shields.io/badge/dynamic/json.svg?label=release&url=https://gitea.com/api/v1/repos/gitea/tea/releases&query=$[0].tag_name)](https://gitea.com/gitea/tea/releases)
[![Join the chat at https://img.shields.io/discord/322538954119184384.svg](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/Gitea)
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/tea)](https://goreportcard.com/report/code.gitea.io/tea) [![GoDoc](https://pkg.go.dev/badge/code.gitea.io/tea?status.svg)](https://godoc.org/code.gitea.io/tea)
![Tea Release Status](https://gitea.com/gitea/tea/actions/workflows/release-nightly.yml/badge.svg)
## The official CLI interface for gitea
## The official CLI for Gitea
Tea is a command line tool for interacting on one or more Gitea instances.
It uses [code.gitea.io/sdk](https://code.gitea.io/sdk) and interacts with the Gitea API
![demo gif](./demo.gif)
![demo gif](https://dl.gitea.io/screenshots/tea_demo.gif)
```
tea - command line tool to interact with Gitea
version 0.8.0-preview
USAGE
tea command [subcommand] [command options] [arguments...]
DESCRIPTION
tea is a productivity helper for Gitea. It can be used to manage most entities on
one or multiple Gitea instances & provides local helpers like 'tea pr checkout'.
tea tries to make use of context provided by the repository in $PWD if available.
tea works best in a upstream/fork workflow, when the local main branch tracks the
upstream repo. tea assumes that local git state is published on the remote before
doing operations with tea. Configuration is persisted in $XDG_CONFIG_HOME/tea.
COMMANDS
help, h Shows a list of commands or help for one command
ENTITIES:
issues, issue, i List, create and update issues
pulls, pull, pr Manage and checkout pull requests
labels, label Manage issue labels
milestones, milestone, ms List and create milestones
releases, release, r Manage releases
release assets, release asset, r a Manage release attachments
times, time, t Operate on tracked times of a repository's issues & pulls
organizations, organization, org List, create, delete organizations
repos, repo Show repository details
comment, c Add a comment to an issue / pr
HELPERS:
open, o Open something of the repository in web browser
notifications, notification, n Show notifications
clone, C Clone a repository locally
SETUP:
logins, login Log in to a Gitea server
logout Log out from a Gitea server
shellcompletion, autocomplete Install shell completion for tea
whoami Show current logged in user
OPTIONS
--help, -h show help (default: false)
--version, -v print the version (default: false)
EXAMPLES
tea login add # add a login once to get started
tea pulls # list open pulls for the repo in $PWD
tea pulls --repo $HOME/foo # list open pulls for the repo in $HOME/foo
tea pulls --remote upstream # list open pulls for the repo pointed at by
# your local "upstream" git remote
# list open pulls for any gitea repo at the given login instance
tea pulls --repo gitea/tea --login gitea.com
tea milestone issues 0.7.0 # view open issues for milestone '0.7.0'
tea issue 189 # view contents of issue 189
tea open 189 # open web ui for issue 189
tea open milestones # open web ui for milestones
# send gitea desktop notifications every 5 minutes (bash + libnotify)
while :; do tea notifications --mine -o simple | xargs -i notify-send {}; sleep 300; done
ABOUT
Written & maintained by The Gitea Authors.
If you find a bug or want to contribute, we'll welcome you at https://gitea.com/gitea/tea.
More info about Gitea itself on https://about.gitea.com.
```
- [Compare features with other git forge CLIs](./FEATURE-COMPARISON.md)
- tea uses [code.gitea.io/sdk](https://code.gitea.io/sdk) and interacts with the Gitea API.
## Installation
You can use the prebuilt binaries from [dl.gitea.io](https://dl.gitea.io/tea/)
There are different ways to get `tea`:
To install from source, go 1.13 or newer is required:
1. Install via your system package manager:
- macOS via `brew` (official):
```sh
brew install tea
```
- arch linux ([gitea-tea-git](https://aur.archlinux.org/packages/gitea-tea-git), thirdparty)
- alpine linux ([tea](https://pkgs.alpinelinux.org/packages?name=tea&branch=edge), thirdparty)
- Windows via `MSYS2` ([tea](https://packages.msys2.org/base/mingw-w64-tea), thirdparty)
```sh
go get code.gitea.io/tea
go install code.gitea.io/tea
```
2. Use the prebuilt binaries from [dl.gitea.com](https://dl.gitea.com/tea/)
If you have `brew` installed, you can install `tea` via:
3. Install from source: [see *Compilation*](#compilation)
```sh
brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea
brew install tea
```
4. Docker (thirdparty): [tgerczei/tea](https://hub.docker.com/r/tgerczei/tea)
Distribution packages exist for: **alpinelinux ([tea](https://pkgs.alpinelinux.org/packages?name=tea&branch=edge))** and **archlinux ([gitea-tea](https://aur.archlinux.org/packages/gitea-tea))**
## Usage
First of all, you have to create a token on your `personal settings -> application` page of your gitea instance.
Use this token to login with `tea`:
```sh
tea login add --name=try --url=https://try.gitea.io --token=xxxxxx
```
Now you can use the following `tea` subcommands.
Detailed usage information is available via `tea <command> --help`.
```none
login Log in to a Gitea server
logout Log out from a Gitea server
issues List, create and update issues
pulls List, create, checkout and clean pull requests
releases List, create, update and delete releases
repos Operate with repositories
labels Manage issue labels
times Operate on tracked times of a repositorys issues and pulls
open Open something of the repository on web browser
notifications Show notifications
milestones List and create milestones
organizations List, create, delete organizations
help, h Shows a list of commands or help for one command
```
To fetch issues from different repos, use the `--remote` flag (when inside a gitea repository directory) or `--login` & `--repo` flags.
5. asdf (thirdparty): [mvaldes14/asdf-tea](https://github.com/mvaldes14/asdf-tea)
## Compilation
Make sure you have installed a current go version.
To compile the sources yourself run the following:
Make sure you have a current go version installed (1.13 or newer).
```sh
git clone https://gitea.com/gitea/tea.git
cd tea
make
```
- To compile the source yourself with the recommended flags & tags:
```sh
git clone https://gitea.com/gitea/tea.git # or: tea clone gitea.com/gitea/tea ;)
cd tea
make
```
Note that GNU Make (gmake on OpenBSD) is required.
If you want to install the compiled program you have to execute the following command:
```sh
make install
```
This installs the binary into the "bin" folder inside of your GOPATH folder (`go env GOPATH`). It is possible that this folder isn't in your PATH Environment Variable.
- For a quick installation without `git` & `make`, set $version and exec:
```sh
go install code.gitea.io/tea@${version}
```
## Contributing
@ -76,7 +129,6 @@ Fork -> Patch -> Push -> Pull Request
- `make test` run testsuite
- `make vet` run checks (check the order of imports; preventing failure on CI pipeline beforehand)
- `make vendor` when adding new dependencies
- ... (for other development tasks, check the `Makefile`)
**Please** read the [CONTRIBUTING](CONTRIBUTING.md) documentation, it will tell you about internal structures and concepts.

View File

@ -1,7 +1,8 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
//+build vendor
// SPDX-License-Identifier: MIT
//go:build vendor
// +build vendor
package main

54
cmd/admin.go Normal file
View File

@ -0,0 +1,54 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"code.gitea.io/tea/cmd/admin/users"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"github.com/urfave/cli/v2"
)
// CmdAdmin represents the namespace of admin commands.
// The command itself has no functionality, but hosts subcommands.
var CmdAdmin = cli.Command{
Name: "admin",
Usage: "Operations requiring admin access on the Gitea instance",
Aliases: []string{"a"},
Category: catMisc,
Action: func(cmd *cli.Context) error {
return cli.ShowSubcommandHelp(cmd)
},
Subcommands: []*cli.Command{
&cmdAdminUsers,
},
}
var cmdAdminUsers = cli.Command{
Name: "users",
Aliases: []string{"u"},
Usage: "Manage registered users",
Action: func(ctx *cli.Context) error {
if ctx.Args().Len() == 1 {
return runAdminUserDetail(ctx, ctx.Args().First())
}
return users.RunUserList(ctx)
},
Subcommands: []*cli.Command{
&users.CmdUserList,
},
Flags: users.CmdUserList.Flags,
}
func runAdminUserDetail(cmd *cli.Context, u string) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
user, _, err := client.GetUserInfo(u)
if err != nil {
return err
}
print.UserDetails(user)
return nil
}

53
cmd/admin/users/list.go Normal file
View File

@ -0,0 +1,53 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package users
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 userFieldsFlag = flags.FieldsFlag(print.UserFields, []string{
"id", "login", "full_name", "email", "activated",
})
// CmdUserList represents a sub command of users to list users
var CmdUserList = cli.Command{
Name: "list",
Aliases: []string{"ls"},
Usage: "List Users",
Description: "List users",
Action: RunUserList,
Flags: append([]cli.Flag{
userFieldsFlag,
&flags.PaginationPageFlag,
&flags.PaginationLimitFlag,
}, flags.AllDefaultFlags...),
}
// RunUserList list users
func RunUserList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
fields, err := userFieldsFlag.GetValues(cmd)
if err != nil {
return err
}
client := ctx.Login.Client()
users, _, err := client.AdminListUsers(gitea.AdminListUsersOptions{
ListOptions: ctx.GetListOptions(),
})
if err != nil {
return err
}
print.UserList(users, ctx.Output, fields)
return nil
}

28
cmd/attachments.go Normal file
View File

@ -0,0 +1,28 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"code.gitea.io/tea/cmd/attachments"
"code.gitea.io/tea/cmd/flags"
"github.com/urfave/cli/v2"
)
// CmdReleaseAttachments represents a release attachment (file attachment)
var CmdReleaseAttachments = cli.Command{
Name: "assets",
Aliases: []string{"asset", "a"},
Category: catEntities,
Usage: "Manage release assets",
Description: "Manage release assets",
ArgsUsage: " ", // command does not accept arguments
Action: attachments.RunReleaseAttachmentList,
Subcommands: []*cli.Command{
&attachments.CmdReleaseAttachmentList,
&attachments.CmdReleaseAttachmentCreate,
&attachments.CmdReleaseAttachmentDelete,
},
Flags: flags.AllDefaultFlags,
}

64
cmd/attachments/create.go Normal file
View File

@ -0,0 +1,64 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package attachments
import (
"fmt"
"os"
"path/filepath"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"github.com/urfave/cli/v2"
)
// CmdReleaseAttachmentCreate represents a sub command of Release Attachments to create a release attachment
var CmdReleaseAttachmentCreate = cli.Command{
Name: "create",
Aliases: []string{"c"},
Usage: "Create one or more release attachments",
Description: `Create one or more release attachments`,
ArgsUsage: "<release-tag> <asset> [<asset>...]",
Action: runReleaseAttachmentCreate,
Flags: flags.AllDefaultFlags,
}
func runReleaseAttachmentCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
if ctx.Args().Len() < 2 {
return fmt.Errorf("No release tag or assets specified.\nUsage:\t%s", ctx.Command.UsageText)
}
tag := ctx.Args().First()
if len(tag) == 0 {
return fmt.Errorf("Release tag needed to create attachment")
}
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
if err != nil {
return err
}
for _, asset := range ctx.Args().Slice()[1:] {
var file *os.File
if file, err = os.Open(asset); err != nil {
return err
}
filePath := filepath.Base(asset)
if _, _, err = ctx.Login.Client().CreateReleaseAttachment(ctx.Owner, ctx.Repo, release.ID, file, filePath); err != nil {
file.Close()
return err
}
file.Close()
}
return nil
}

100
cmd/attachments/delete.go Normal file
View File

@ -0,0 +1,100 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package attachments
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdReleaseAttachmentDelete represents a sub command of Release Attachments to delete a release attachment
var CmdReleaseAttachmentDelete = cli.Command{
Name: "delete",
Aliases: []string{"rm"},
Usage: "Delete one or more release attachments",
Description: `Delete one or more release attachments`,
ArgsUsage: "<release tag> <attachment name> [<attachment name>...]",
Action: runReleaseAttachmentDelete,
Flags: append([]cli.Flag{
&cli.BoolFlag{
Name: "confirm",
Aliases: []string{"y"},
Usage: "Confirm deletion (required)",
},
}, flags.AllDefaultFlags...),
}
func runReleaseAttachmentDelete(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
if ctx.Args().Len() < 2 {
return fmt.Errorf("No release tag or attachment names specified.\nUsage:\t%s", ctx.Command.UsageText)
}
tag := ctx.Args().First()
if len(tag) == 0 {
return fmt.Errorf("Release tag needed to delete attachment")
}
if !ctx.Bool("confirm") {
fmt.Println("Are you sure? Please confirm with -y or --confirm.")
return nil
}
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
if err != nil {
return err
}
existing, _, err := client.ListReleaseAttachments(ctx.Owner, ctx.Repo, release.ID, gitea.ListReleaseAttachmentsOptions{
ListOptions: gitea.ListOptions{Page: -1},
})
if err != nil {
return err
}
for _, name := range ctx.Args().Slice()[1:] {
var attachment *gitea.Attachment
for _, a := range existing {
if a.Name == name {
attachment = a
}
}
if attachment == nil {
return fmt.Errorf("Release does not have attachment named '%s'", name)
}
_, err = client.DeleteReleaseAttachment(ctx.Owner, ctx.Repo, release.ID, attachment.ID)
if err != nil {
return err
}
}
return nil
}
func getReleaseAttachmentByName(owner, repo string, release int64, name string, client *gitea.Client) (*gitea.Attachment, error) {
al, _, err := client.ListReleaseAttachments(owner, repo, release, gitea.ListReleaseAttachmentsOptions{
ListOptions: gitea.ListOptions{Page: -1},
})
if err != nil {
return nil, err
}
if len(al) == 0 {
return nil, fmt.Errorf("Release does not have any attachments")
}
for _, a := range al {
if a.Name == name {
return a, nil
}
}
return nil, fmt.Errorf("Attachment does not exist")
}

74
cmd/attachments/list.go Normal file
View File

@ -0,0 +1,74 @@
// Copyright 2024 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package attachments
import (
"fmt"
"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"
)
// CmdReleaseAttachmentList represents a sub command of release attachment to list release attachments
var CmdReleaseAttachmentList = cli.Command{
Name: "list",
Aliases: []string{"ls"},
Usage: "List Release Attachments",
Description: "List Release Attachments",
ArgsUsage: "<release-tag>", // command does not accept arguments
Action: RunReleaseAttachmentList,
Flags: append([]cli.Flag{
&flags.PaginationPageFlag,
&flags.PaginationLimitFlag,
}, flags.AllDefaultFlags...),
}
// RunReleaseAttachmentList list release attachments
func RunReleaseAttachmentList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
tag := ctx.Args().First()
if len(tag) == 0 {
return fmt.Errorf("Release tag needed to list attachments")
}
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
if err != nil {
return err
}
attachments, _, err := ctx.Login.Client().ListReleaseAttachments(ctx.Owner, ctx.Repo, release.ID, gitea.ListReleaseAttachmentsOptions{
ListOptions: ctx.GetListOptions(),
})
if err != nil {
return err
}
print.ReleaseAttachmentsList(attachments, ctx.Output)
return nil
}
func getReleaseByTag(owner, repo, tag string, client *gitea.Client) (*gitea.Release, error) {
rl, _, err := client.ListReleases(owner, repo, gitea.ListReleasesOptions{
ListOptions: gitea.ListOptions{Page: -1},
})
if err != nil {
return nil, err
}
if len(rl) == 0 {
return nil, fmt.Errorf("Repo does not have any release")
}
for _, r := range rl {
if r.TagName == tag {
return r, nil
}
}
return nil, fmt.Errorf("Release tag does not exist")
}

137
cmd/autocomplete.go Normal file
View File

@ -0,0 +1,137 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"io"
"net/http"
"os"
"os/exec"
"github.com/adrg/xdg"
"github.com/urfave/cli/v2"
)
// CmdAutocomplete manages autocompletion
var CmdAutocomplete = cli.Command{
Name: "shellcompletion",
Aliases: []string{"autocomplete"},
Category: catSetup,
Usage: "Install shell completion for tea",
Description: "Install shell completion for tea",
ArgsUsage: "<shell type> (bash, zsh, powershell, fish)",
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "install",
Usage: "Persist in shell config instead of printing commands",
},
},
Action: runAutocompleteAdd,
}
func runAutocompleteAdd(ctx *cli.Context) error {
var remoteFile, localFile, cmds string
shell := ctx.Args().First()
switch shell {
case "zsh":
remoteFile = "contrib/autocomplete.zsh"
localFile = "autocomplete.zsh"
cmds = "echo 'PROG=tea _CLI_ZSH_AUTOCOMPLETE_HACK=1 source \"%s\"' >> ~/.zshrc && source ~/.zshrc"
case "bash":
remoteFile = "contrib/autocomplete.sh"
localFile = "autocomplete.sh"
cmds = "echo 'PROG=tea source \"%s\"' >> ~/.bashrc && source ~/.bashrc"
case "powershell":
remoteFile = "contrib/autocomplete.ps1"
localFile = "tea.ps1"
cmds = "\"& %s\" >> $profile"
case "fish":
// fish is different, in that urfave/cli provides a generator for the shell script needed.
// this also means that the fish completion can become out of sync with the tea binary!
// writing to this directory suffices, as fish reads files there on startup, no cmds needed.
return writeFishAutoCompleteFile(ctx)
default:
return fmt.Errorf("Must specify valid %s", ctx.Command.ArgsUsage)
}
localPath, err := xdg.ConfigFile("tea/" + localFile)
if err != nil {
return err
}
cmds = fmt.Sprintf(cmds, localPath)
if err = writeRemoteAutoCompleteFile(remoteFile, localPath); err != nil {
return err
}
if ctx.Bool("install") {
fmt.Println("Installing in your shellrc")
installer := exec.Command(shell, "-c", cmds)
if shell == "powershell" {
installer = exec.Command("powershell.exe", "-Command", cmds)
}
out, err := installer.CombinedOutput()
if err != nil {
return fmt.Errorf("Couldn't run the commands: %s %s", err, out)
}
} else {
fmt.Println("\n# Run the following commands to install autocompletion (or use --install)")
fmt.Println(cmds)
}
return nil
}
func writeRemoteAutoCompleteFile(file, destPath string) error {
url := fmt.Sprintf("https://gitea.com/gitea/tea/raw/branch/master/%s", file)
fmt.Println("Fetching " + url)
res, err := http.Get(url)
if err != nil {
return err
}
defer res.Body.Close()
writer, err := os.Create(destPath)
if err != nil {
return err
}
defer writer.Close()
_, err = io.Copy(writer, res.Body)
return err
}
func writeFishAutoCompleteFile(ctx *cli.Context) error {
// NOTE: to make sure this file is in sync with tea commands, we'd need to
// - check if the file exists
// - if it does, check if the tea version that wrote it is the currently running version
// - if not, rewrite the file
// on each application run
// NOTE: this generates a completion that also suggests file names, which looks kinda messy..
script, err := ctx.App.ToFishCompletion()
if err != nil {
return err
}
localPath, err := xdg.ConfigFile("fish/conf.d/tea_completion.fish")
if err != nil {
return err
}
writer, err := os.Create(localPath)
if err != nil {
return err
}
if _, err = io.WriteString(writer, script); err != nil {
return err
}
fmt.Printf("Installed tab completion to %s\n", localPath)
return nil
}

36
cmd/branches.go Normal file
View File

@ -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: "[<branch name>]",
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)
}

73
cmd/branches/list.go Normal file
View File

@ -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
}

101
cmd/branches/protect.go Normal file
View File

@ -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: "<branch>",
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: "<branch>",
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
}

11
cmd/categories.go Normal file
View File

@ -0,0 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
var (
catSetup = "SETUP"
catEntities = "ENTITIES"
catHelpers = "HELPERS"
catMisc = "MISCELLANEOUS"
)

88
cmd/clone.go Normal file
View File

@ -0,0 +1,88 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/git"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/task"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
)
// CmdRepoClone represents a sub command of repos to create a local copy
var CmdRepoClone = cli.Command{
Name: "clone",
Aliases: []string{"C"},
Usage: "Clone a repository locally",
Description: `Clone a repository locally, without a local git installation required.
The repo slug can be specified in different formats:
gitea/tea
tea
gitea.com/gitea/tea
git@gitea.com:gitea/tea
https://gitea.com/gitea/tea
ssh://gitea.com:22/gitea/tea
When a host is specified in the repo-slug, it will override the login specified with --login.
`,
Category: catHelpers,
Action: runRepoClone,
ArgsUsage: "<repo-slug> [target dir]",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "depth",
Aliases: []string{"d"},
Usage: "num commits to fetch, defaults to all",
},
&flags.LoginFlag,
},
}
func runRepoClone(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
args := ctx.Args()
if args.Len() < 1 {
return cli.ShowCommandHelp(cmd, "clone")
}
dir := args.Get(1)
var (
login *config.Login = ctx.Login
owner string = ctx.Login.User
repo string
)
// parse first arg as repo specifier
repoSlug := args.Get(0)
url, err := git.ParseURL(repoSlug)
if err != nil {
return err
}
owner, repo = utils.GetOwnerAndRepo(url.Path, login.User)
if url.Host != "" {
login = config.GetLoginByHost(url.Host)
if login == nil {
return fmt.Errorf("No login configured matching host '%s', run `tea login add` first", url.Host)
}
}
_, err = task.RepoClone(
dir,
login,
owner,
repo,
interact.PromptPassword,
ctx.Int("depth"),
)
return err
}

82
cmd/comment.go Normal file
View File

@ -0,0 +1,82 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"io"
"strings"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
"code.gitea.io/sdk/gitea"
"github.com/AlecAivazis/survey/v2"
"github.com/urfave/cli/v2"
)
// CmdAddComment is the main command to operate with notifications
var CmdAddComment = cli.Command{
Name: "comment",
Aliases: []string{"c"},
Category: catEntities,
Usage: "Add a comment to an issue / pr",
Description: "Add a comment to an issue / pr",
ArgsUsage: "<issue / pr index> [<comment body>]",
Action: runAddComment,
Flags: flags.AllDefaultFlags,
}
func runAddComment(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
args := ctx.Args()
if args.Len() == 0 {
return fmt.Errorf("Please specify issue / pr index")
}
idx, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
return err
}
body := strings.Join(ctx.Args().Tail(), " ")
if interact.IsStdinPiped() {
// custom solution until https://github.com/AlecAivazis/survey/issues/328 is fixed
if bodyStdin, err := io.ReadAll(ctx.App.Reader); err != nil {
return err
} else if len(bodyStdin) != 0 {
body = strings.Join([]string{body, string(bodyStdin)}, "\n\n")
}
} else if len(body) == 0 {
if err = survey.AskOne(interact.NewMultiline(interact.Multiline{
Message: "Comment:",
Syntax: "md",
UseEditor: config.GetPreferences().Editor,
}), &body); err != nil {
return err
}
}
if len(body) == 0 {
return fmt.Errorf("No comment body provided")
}
client := ctx.Login.Client()
comment, _, err := client.CreateIssueComment(ctx.Owner, ctx.Repo, idx, gitea.CreateIssueCommentOption{
Body: body,
})
if err != nil {
return err
}
print.Comment(comment)
return nil
}

55
cmd/docs.go Normal file
View File

@ -0,0 +1,55 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"os"
"path/filepath"
"github.com/urfave/cli/v2"
)
// CmdDocs generates markdown for tea
var CmdDocs = cli.Command{
Name: "docs",
Hidden: true,
Description: "Generate CLI docs",
Action: runDocs,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "out",
Usage: "Path to output docs to, otherwise prints to stdout",
Aliases: []string{"o"},
},
},
}
func runDocs(ctx *cli.Context) error {
md, err := ctx.App.ToMarkdown()
if err != nil {
return err
}
outPath := ctx.String("out")
if outPath == "" {
fmt.Print(md)
return nil
}
if err := os.MkdirAll(filepath.Dir(outPath), os.ModePerm); err != nil {
return err
}
fi, err := os.Create(outPath)
if err != nil {
return err
}
defer fi.Close()
if _, err := fi.WriteString(md); err != nil {
return err
}
return nil
}

52
cmd/flags/csvflag.go Normal file
View File

@ -0,0 +1,52 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package flags
import (
"fmt"
"strings"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
)
// CsvFlag is a wrapper around cli.StringFlag, with an added GetValues() method
// to retrieve comma separated string values as a slice.
type CsvFlag struct {
cli.StringFlag
AvailableFields []string
}
// NewCsvFlag creates a CsvFlag, while setting its usage string and default values
func NewCsvFlag(name, usage string, aliases, availableValues, defaults []string) *CsvFlag {
var availableDesc string
if len(availableValues) != 0 {
availableDesc = " Available values:"
}
return &CsvFlag{
AvailableFields: availableValues,
StringFlag: cli.StringFlag{
Name: name,
Aliases: aliases,
Value: strings.Join(defaults, ","),
Usage: fmt.Sprintf(`Comma-separated list of %s.%s
%s
`, usage, availableDesc, strings.Join(availableValues, ",")),
},
}
}
// GetValues returns the value of the flag, parsed as a commaseparated list
func (f CsvFlag) GetValues(ctx *cli.Context) ([]string, error) {
val := ctx.String(f.Name)
selection := strings.Split(val, ",")
if f.AvailableFields != nil && val != "" {
for _, field := range selection {
if !utils.Contains(f.AvailableFields, field) {
return nil, fmt.Errorf("Invalid field '%s'", field)
}
}
}
return selection, nil
}

View File

@ -1,64 +1,38 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package flags
import (
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// create global variables for global Flags to simplify
// access to the options without requiring cli.Context
var (
// GlobalLoginValue contain value of --login|-l arg
GlobalLoginValue string
// GlobalRepoValue contain value of --repo|-r arg
GlobalRepoValue string
// GlobalOutputValue contain value of --output|-o arg
GlobalOutputValue string
// GlobalRemoteValue contain value of --remote|-R arg
GlobalRemoteValue string
)
// LoginFlag provides flag to specify tea login profile
var LoginFlag = cli.StringFlag{
Name: "login",
Aliases: []string{"l"},
Usage: "Use a different Gitea login. Optional",
Destination: &GlobalLoginValue,
Name: "login",
Aliases: []string{"l"},
Usage: "Use a different Gitea Login. Optional",
}
// RepoFlag provides flag to specify repository
var RepoFlag = cli.StringFlag{
Name: "repo",
Aliases: []string{"r"},
Usage: "Override local repository path or gitea repository slug to interact with. Optional",
Destination: &GlobalRepoValue,
Name: "repo",
Aliases: []string{"r"},
Usage: "Override local repository path or gitea repository slug to interact with. Optional",
}
// RemoteFlag provides flag to specify remote repository
var RemoteFlag = cli.StringFlag{
Name: "remote",
Aliases: []string{"R"},
Usage: "Discover Gitea login from remote. Optional",
Destination: &GlobalRemoteValue,
Name: "remote",
Aliases: []string{"R"},
Usage: "Discover Gitea login from remote. Optional",
}
// OutputFlag provides flag to specify output type
var OutputFlag = cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Usage: "Output format. (csv, simple, table, tsv, yaml)",
Destination: &GlobalOutputValue,
}
// StateFlag provides flag to specify issue/pr state, defaulting to "open"
var StateFlag = cli.StringFlag{
Name: "state",
Usage: "Filter by state (all|open|closed)",
DefaultText: "open",
Name: "output",
Aliases: []string{"o"},
Usage: "Output format. (simple, table, csv, tsv, yaml, json)",
}
// PaginationPageFlag provides flag for pagination options
@ -103,22 +77,29 @@ var AllDefaultFlags = append([]cli.Flag{
&RemoteFlag,
}, LoginOutputFlags...)
// IssuePRFlags defines flags that should be available on issue & pr listing flags.
var IssuePRFlags = append([]cli.Flag{
&StateFlag,
// NotificationFlags defines flags that should be available on notifications.
var NotificationFlags = append([]cli.Flag{
NotificationStateFlag,
&cli.BoolFlag{
Name: "mine",
Aliases: []string{"m"},
Usage: "Show notifications across all your repositories instead of the current repository only",
},
&PaginationPageFlag,
&PaginationLimitFlag,
}, AllDefaultFlags...)
// GetListOptions return ListOptions based on PaginationFlags
func GetListOptions(ctx *cli.Context) gitea.ListOptions {
page := ctx.Int("page")
limit := ctx.Int("limit")
if limit != 0 && page == 0 {
page = 1
}
return gitea.ListOptions{
Page: page,
PageSize: limit,
}
// NotificationStateFlag is a csv flag applied to all notification subcommands as filter
var NotificationStateFlag = NewCsvFlag(
"states",
"notification states to filter by",
[]string{"s"},
[]string{"pinned", "unread", "read"},
[]string{"unread", "pinned"},
)
// FieldsFlag generates a flag selecting printable fields.
// To retrieve the value, use f.GetValues()
func FieldsFlag(availableFields, defaultFields []string) *CsvFlag {
return NewCsvFlag("fields", "fields to print", []string{"f"}, availableFields, defaultFields)
}

238
cmd/flags/issue_pr.go Normal file
View File

@ -0,0 +1,238 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package flags
import (
"fmt"
"strings"
"time"
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/task"
"github.com/araddon/dateparse"
"github.com/urfave/cli/v2"
)
// StateFlag provides flag to specify issue/pr state, defaulting to "open"
var StateFlag = cli.StringFlag{
Name: "state",
Usage: "Filter by state (all|open|closed)",
DefaultText: "open",
}
// MilestoneFilterFlag is a CSV flag used to filter issues by milestones
var MilestoneFilterFlag = NewCsvFlag(
"milestones",
"milestones to match issues against",
[]string{"m"}, nil, nil)
// LabelFilterFlag is a CSV flag used to filter issues by labels
var LabelFilterFlag = NewCsvFlag(
"labels",
"labels to match issues against",
[]string{"L"}, nil, nil)
// PRListingFlags defines flags that should be available on pr listing flags.
var PRListingFlags = append([]cli.Flag{
&StateFlag,
&PaginationPageFlag,
&PaginationLimitFlag,
}, AllDefaultFlags...)
// IssueListingFlags defines flags that should be available on issue listing flags.
var IssueListingFlags = append([]cli.Flag{
&StateFlag,
&cli.StringFlag{
Name: "kind",
Aliases: []string{"K"},
Usage: "Whether to return `issues`, `pulls`, or `all` (you can use this to apply advanced search filters to PRs)",
DefaultText: "issues",
},
&cli.StringFlag{
Name: "keyword",
Aliases: []string{"k"},
Usage: "Filter by search string",
},
LabelFilterFlag,
MilestoneFilterFlag,
&cli.StringFlag{
Name: "author",
Aliases: []string{"A"},
},
&cli.StringFlag{
Name: "assignee",
Aliases: []string{"a"},
},
&cli.StringFlag{
Name: "mentions",
Aliases: []string{"M"},
},
&cli.StringFlag{
Name: "owner",
Aliases: []string{"org"},
},
&cli.StringFlag{
Name: "from",
Aliases: []string{"F"},
Usage: "Filter by activity after this date",
},
&cli.StringFlag{
Name: "until",
Aliases: []string{"u"},
Usage: "Filter by activity before this date",
},
&PaginationPageFlag,
&PaginationLimitFlag,
}, AllDefaultFlags...)
// issuePRFlags defines shared flags between flags IssuePRCreateFlags and IssuePREditFlags
var issuePRFlags = append([]cli.Flag{
&cli.StringFlag{
Name: "title",
Aliases: []string{"t"},
},
&cli.StringFlag{
Name: "description",
Aliases: []string{"d"},
},
&cli.StringFlag{
Name: "referenced-version",
Aliases: []string{"v"},
Usage: "commit-hash or tag name to assign",
},
&cli.StringFlag{
Name: "milestone",
Aliases: []string{"m"},
Usage: "Milestone to assign",
},
&cli.StringFlag{
Name: "deadline",
Aliases: []string{"D"},
Usage: "Deadline timestamp to assign",
},
}, LoginRepoFlags...)
// IssuePRCreateFlags defines flags for creation of issues and PRs
var IssuePRCreateFlags = append([]cli.Flag{
&cli.StringFlag{
Name: "assignees",
Aliases: []string{"a"},
Usage: "Comma-separated list of usernames to assign",
},
&cli.StringFlag{
Name: "labels",
Aliases: []string{"L"},
Usage: "Comma-separated list of labels to assign",
},
}, issuePRFlags...)
// GetIssuePRCreateFlags parses all IssuePREditFlags
func GetIssuePRCreateFlags(ctx *context.TeaContext) (*gitea.CreateIssueOption, error) {
opts := gitea.CreateIssueOption{
Title: ctx.String("title"),
Body: ctx.String("description"),
Assignees: strings.Split(ctx.String("assignees"), ","),
}
var err error
date := ctx.String("deadline")
if date != "" {
t, err := dateparse.ParseAny(date)
if err != nil {
return nil, err
}
opts.Deadline = &t
}
client := ctx.Login.Client()
labelNames := strings.Split(ctx.String("labels"), ",")
if len(labelNames) != 0 {
if client == nil {
client = ctx.Login.Client()
}
if opts.Labels, err = task.ResolveLabelNames(client, ctx.Owner, ctx.Repo, labelNames); err != nil {
return nil, err
}
}
if milestoneName := ctx.String("milestone"); len(milestoneName) != 0 {
if client == nil {
client = ctx.Login.Client()
}
ms, _, err := client.GetMilestoneByName(ctx.Owner, ctx.Repo, milestoneName)
if err != nil {
return nil, fmt.Errorf("Milestone '%s' not found", milestoneName)
}
opts.Milestone = ms.ID
}
return &opts, nil
}
// IssuePREditFlags defines flags for editing properties of issues and PRs
var IssuePREditFlags = append([]cli.Flag{
&cli.StringFlag{
Name: "add-assignees",
Aliases: []string{"a"},
Usage: "Comma-separated list of usernames to assign",
},
&cli.StringFlag{
Name: "add-labels",
Aliases: []string{"L"},
Usage: "Comma-separated list of labels to assign. Takes precedence over --remove-labels",
},
&cli.StringFlag{
Name: "remove-labels",
Usage: "Comma-separated list of labels to remove",
},
}, issuePRFlags...)
// GetIssuePREditFlags parses all IssuePREditFlags
func GetIssuePREditFlags(ctx *context.TeaContext) (*task.EditIssueOption, error) {
opts := task.EditIssueOption{}
if ctx.IsSet("title") {
val := ctx.String("title")
opts.Title = &val
}
if ctx.IsSet("description") {
val := ctx.String("description")
opts.Body = &val
}
if ctx.IsSet("referenced-version") {
val := ctx.String("referenced-version")
opts.Ref = &val
}
if ctx.IsSet("milestone") {
val := ctx.String("milestone")
opts.Milestone = &val
}
if ctx.IsSet("deadline") {
date := ctx.String("deadline")
if date == "" {
opts.Deadline = &time.Time{}
} else {
t, err := dateparse.ParseAny(date)
if err != nil {
return nil, err
}
opts.Deadline = &t
}
}
if ctx.IsSet("add-assignees") {
val := ctx.String("add-assignees")
opts.AddAssignees = strings.Split(val, ",")
}
if ctx.IsSet("add-labels") {
val := ctx.String("add-labels")
opts.AddLabels = strings.Split(val, ",")
}
if ctx.IsSet("remove-labels") {
val := ctx.String("remove-labels")
opts.RemoveLabels = strings.Split(val, ",")
}
return &opts, nil
}

View File

@ -1,13 +1,14 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"code.gitea.io/tea/cmd/flags"
"fmt"
"code.gitea.io/tea/cmd/issues"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
@ -17,38 +18,59 @@ import (
// CmdIssues represents to login a gitea server.
var CmdIssues = cli.Command{
Name: "issues",
Aliases: []string{"issue"},
Aliases: []string{"issue", "i"},
Category: catEntities,
Usage: "List, create and update issues",
Description: "List, create and update issues",
Description: `Lists issues when called without argument. If issue index is provided, will show it in detail.`,
ArgsUsage: "[<issue index>]",
Action: runIssues,
Subcommands: []*cli.Command{
&issues.CmdIssuesList,
&issues.CmdIssuesCreate,
&issues.CmdIssuesEdit,
&issues.CmdIssuesReopen,
&issues.CmdIssuesClose,
},
Flags: flags.IssuePRFlags,
Flags: append([]cli.Flag{
&cli.BoolFlag{
Name: "comments",
Usage: "Whether to display comments (will prompt if not provided & run interactively)",
},
}, issues.CmdIssuesList.Flags...),
}
func runIssues(ctx *cli.Context) error {
if ctx.Args().Len() == 1 {
return runIssueDetail(ctx.Args().First())
return runIssueDetail(ctx, ctx.Args().First())
}
return issues.RunIssuesList(ctx)
}
func runIssueDetail(index string) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runIssueDetail(cmd *cli.Context, index string) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
idx, err := utils.ArgToIndex(index)
if err != nil {
return err
}
issue, _, err := login.Client().GetIssue(owner, repo, idx)
client := ctx.Login.Client()
issue, _, err := client.GetIssue(ctx.Owner, ctx.Repo, idx)
if err != nil {
return err
}
print.IssueDetails(issue)
reactions, _, err := client.GetIssueReactions(ctx.Owner, ctx.Repo, idx)
if err != nil {
return err
}
print.IssueDetails(issue, reactions)
if issue.Comments > 0 {
err = interact.ShowCommentsMaybeInteractive(ctx, idx, issue.Comments)
if err != nil {
return fmt.Errorf("error loading comments: %v", err)
}
}
return nil
}

View File

@ -1,14 +1,13 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package issues
import (
"log"
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
@ -19,9 +18,9 @@ import (
// CmdIssuesClose represents a sub command of issues to close an issue
var CmdIssuesClose = cli.Command{
Name: "close",
Usage: "Change state of an issue to 'closed'",
Description: `Change state of an issue to 'closed'`,
ArgsUsage: "<issue index>",
Usage: "Change state of one ore more issues to 'closed'",
Description: `Change state of one ore more issues to 'closed'`,
ArgsUsage: "<issue index> [<issue index>...]",
Action: func(ctx *cli.Context) error {
var s = gitea.StateClosed
return editIssueState(ctx, gitea.EditIssueOption{State: &s})
@ -30,22 +29,30 @@ var CmdIssuesClose = cli.Command{
}
// editIssueState abstracts the arg parsing to edit the given issue
func editIssueState(ctx *cli.Context, opts gitea.EditIssueOption) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func editIssueState(cmd *cli.Context, opts gitea.EditIssueOption) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() == 0 {
log.Fatal(ctx.Command.ArgsUsage)
return fmt.Errorf(ctx.Command.ArgsUsage)
}
index, err := utils.ArgToIndex(ctx.Args().First())
indices, err := utils.ArgsToIndices(ctx.Args().Slice())
if err != nil {
return err
}
issue, _, err := login.Client().EditIssue(owner, repo, index, opts)
if err != nil {
return err
}
client := ctx.Login.Client()
for _, index := range indices {
issue, _, err := client.EditIssue(ctx.Owner, ctx.Repo, index, opts)
if err != nil {
return err
}
print.IssueDetails(issue)
if len(indices) > 1 {
fmt.Println(issue.HTMLURL)
} else {
print.IssueDetails(issue, nil)
}
}
return nil
}

View File

@ -1,61 +1,45 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package issues
import (
"fmt"
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/task"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdIssuesCreate represents a sub command of issues to create issue
var CmdIssuesCreate = cli.Command{
Name: "create",
Aliases: []string{"c"},
Usage: "Create an issue on repository",
Description: `Create an issue on repository`,
ArgsUsage: " ", // command does not accept arguments
Action: runIssuesCreate,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "title",
Aliases: []string{"t"},
Usage: "issue title to create",
},
&cli.StringFlag{
Name: "body",
Aliases: []string{"b"},
Usage: "issue body to create",
},
}, flags.LoginRepoFlags...),
Flags: flags.IssuePRCreateFlags,
}
func runIssuesCreate(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runIssuesCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
issue, _, err := login.Client().CreateIssue(owner, repo, gitea.CreateIssueOption{
Title: ctx.String("title"),
Body: ctx.String("body"),
// TODO:
//Assignee string `json:"assignee"`
//Assignees []string `json:"assignees"`
//Deadline *time.Time `json:"due_date"`
//Milestone int64 `json:"milestone"`
//Labels []int64 `json:"labels"`
//Closed bool `json:"closed"`
})
if err != nil {
log.Fatal(err)
if ctx.NumFlags() == 0 {
return interact.CreateIssue(ctx.Login, ctx.Owner, ctx.Repo)
}
print.IssueDetails(issue)
fmt.Println(issue.HTMLURL)
return nil
opts, err := flags.GetIssuePRCreateFlags(ctx)
if err != nil {
return err
}
return task.CreateIssue(
ctx.Login,
ctx.Owner,
ctx.Repo,
*opts,
)
}

62
cmd/issues/edit.go Normal file
View File

@ -0,0 +1,62 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package issues
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/task"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
)
// CmdIssuesEdit is the subcommand of issues to edit issues
var CmdIssuesEdit = cli.Command{
Name: "edit",
Aliases: []string{"e"},
Usage: "Edit one or more issues",
Description: `Edit one or more issues. To unset a property again,
use an empty string (eg. --milestone "").`,
ArgsUsage: "<idx> [<idx>...]",
Action: runIssuesEdit,
Flags: flags.IssuePREditFlags,
}
func runIssuesEdit(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 issue index")
}
opts, err := flags.GetIssuePREditFlags(ctx)
if err != nil {
return err
}
indices, err := utils.ArgsToIndices(ctx.Args().Slice())
if err != nil {
return err
}
client := ctx.Login.Client()
for _, opts.Index = range indices {
issue, err := task.EditIssue(ctx, client, *opts)
if err != nil {
return err
}
if ctx.Args().Len() > 1 {
fmt.Println(issue.HTMLURL)
} else {
print.IssueDetails(issue, nil)
}
}
return nil
}

View File

@ -1,54 +1,131 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package issues
import (
"log"
"fmt"
"time"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
"github.com/araddon/dateparse"
"github.com/urfave/cli/v2"
)
var issueFieldsFlag = flags.FieldsFlag(print.IssueFields, []string{
"index", "title", "state", "author", "milestone", "labels", "owner", "repo",
})
// CmdIssuesList represents a sub command of issues to list issues
var CmdIssuesList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List issues of the repository",
Description: `List issues of the repository`,
ArgsUsage: " ", // command does not accept arguments
Action: RunIssuesList,
Flags: flags.IssuePRFlags,
Flags: append([]cli.Flag{issueFieldsFlag}, flags.IssueListingFlags...),
}
// RunIssuesList list issues
func RunIssuesList(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func RunIssuesList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
state := gitea.StateOpen
switch ctx.String("state") {
case "all":
state = gitea.StateAll
case "open":
case "", "open":
state = gitea.StateOpen
case "closed":
state = gitea.StateClosed
default:
return fmt.Errorf("unknown state '%s'", ctx.String("state"))
}
issues, _, err := login.Client().ListRepoIssues(owner, repo, gitea.ListIssueOption{
ListOptions: flags.GetListOptions(ctx),
State: state,
Type: gitea.IssueTypeIssue,
})
kind := gitea.IssueTypeIssue
switch ctx.String("kind") {
case "", "issues", "issue":
kind = gitea.IssueTypeIssue
case "pulls", "pull", "pr":
kind = gitea.IssueTypePull
case "all":
kind = gitea.IssueTypeAll
default:
return fmt.Errorf("unknown kind '%s'", ctx.String("kind"))
}
var err error
var from, until time.Time
if ctx.IsSet("from") {
from, err = dateparse.ParseLocal(ctx.String("from"))
if err != nil {
return err
}
}
if ctx.IsSet("until") {
until, err = dateparse.ParseLocal(ctx.String("until"))
if err != nil {
return err
}
}
owner := ctx.Owner
if ctx.IsSet("owner") {
owner = ctx.String("owner")
}
// ignore error, as we don't do any input validation on these flags
labels, _ := flags.LabelFilterFlag.GetValues(cmd)
milestones, _ := flags.MilestoneFilterFlag.GetValues(cmd)
var issues []*gitea.Issue
if ctx.Repo != "" {
issues, _, err = ctx.Login.Client().ListRepoIssues(owner, ctx.Repo, gitea.ListIssueOption{
ListOptions: ctx.GetListOptions(),
State: state,
Type: kind,
KeyWord: ctx.String("keyword"),
CreatedBy: ctx.String("author"),
AssignedBy: ctx.String("assigned-to"),
MentionedBy: ctx.String("mentions"),
Labels: labels,
Milestones: milestones,
Since: from,
Before: until,
})
if err != nil {
return err
}
} else {
issues, _, err = ctx.Login.Client().ListIssues(gitea.ListIssueOption{
ListOptions: ctx.GetListOptions(),
State: state,
Type: kind,
KeyWord: ctx.String("keyword"),
CreatedBy: ctx.String("author"),
AssignedBy: ctx.String("assigned-to"),
MentionedBy: ctx.String("mentions"),
Labels: labels,
Milestones: milestones,
Since: from,
Before: until,
Owner: owner,
})
if err != nil {
return err
}
}
fields, err := issueFieldsFlag.GetValues(cmd)
if err != nil {
log.Fatal(err)
return err
}
print.IssuesList(issues, flags.GlobalOutputValue)
print.IssuesPullsList(issues, ctx.Output, fields)
return nil
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package issues
@ -15,9 +14,9 @@ import (
var CmdIssuesReopen = cli.Command{
Name: "reopen",
Aliases: []string{"open"},
Usage: "Change state of an issue to 'open'",
Description: `Change state of an issue to 'open'`,
ArgsUsage: "<issue index>",
Usage: "Change state of one or more issues to 'open'",
Description: `Change state of one or more issues to 'open'`,
ArgsUsage: "<issue index> [<issue index>...]",
Action: func(ctx *cli.Context) error {
var s = gitea.StateOpen
return editIssueState(ctx, gitea.EditIssueOption{State: &s})

View File

@ -1,11 +1,10 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"log"
"fmt"
"code.gitea.io/tea/cmd/labels"
"github.com/urfave/cli/v2"
@ -15,8 +14,10 @@ import (
var CmdLabels = cli.Command{
Name: "labels",
Aliases: []string{"label"},
Category: catEntities,
Usage: "Manage issue labels",
Description: `Manage issue labels`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabels,
Subcommands: []*cli.Command{
&labels.CmdLabelsList,
@ -24,6 +25,7 @@ var CmdLabels = cli.Command{
&labels.CmdLabelUpdate,
&labels.CmdLabelDelete,
},
Flags: labels.CmdLabelsList.Flags,
}
func runLabels(ctx *cli.Context) error {
@ -34,6 +36,5 @@ func runLabels(ctx *cli.Context) error {
}
func runLabelsDetails(ctx *cli.Context) error {
log.Fatal("Not yet implemented.")
return nil
return fmt.Errorf("Not yet implemented")
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package labels
@ -11,7 +10,7 @@ import (
"strings"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
@ -20,10 +19,12 @@ import (
// CmdLabelCreate represents a sub command of labels to create label.
var CmdLabelCreate = cli.Command{
Name: "create",
Aliases: []string{"c"},
Usage: "Create a label",
Description: `Create a label`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabelCreate,
Flags: []cli.Flag{
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "label name",
@ -40,16 +41,17 @@ var CmdLabelCreate = cli.Command{
Name: "file",
Usage: "indicate a label file",
},
},
}, flags.AllDefaultFlags...),
}
func runLabelCreate(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runLabelCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
labelFile := ctx.String("file")
var err error
if len(labelFile) == 0 {
_, _, err = login.Client().CreateLabel(owner, repo, gitea.CreateLabelOption{
_, _, err = ctx.Login.Client().CreateLabel(ctx.Owner, ctx.Repo, gitea.CreateLabelOption{
Name: ctx.String("name"),
Color: ctx.String("color"),
Description: ctx.String("description"),
@ -69,7 +71,7 @@ func runLabelCreate(ctx *cli.Context) error {
if color == "" || name == "" {
log.Printf("Line %d ignored because lack of enough fields: %s\n", i, line)
} else {
_, _, err = login.Client().CreateLabel(owner, repo, gitea.CreateLabelOption{
_, _, err = ctx.Login.Client().CreateLabel(ctx.Owner, ctx.Repo, gitea.CreateLabelOption{
Name: name,
Color: color,
Description: description,
@ -80,11 +82,7 @@ func runLabelCreate(ctx *cli.Context) error {
}
}
if err != nil {
log.Fatal(err)
}
return nil
return err
}
func splitLabelLine(line string) (string, string, string) {

View File

@ -1,6 +1,5 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package labels

View File

@ -1,14 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package labels
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"github.com/urfave/cli/v2"
)
@ -16,24 +13,23 @@ import (
// CmdLabelDelete represents a sub command of labels to delete label.
var CmdLabelDelete = cli.Command{
Name: "delete",
Aliases: []string{"rm"},
Usage: "Delete a label",
Description: `Delete a label`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabelDelete,
Flags: []cli.Flag{
Flags: append([]cli.Flag{
&cli.IntFlag{
Name: "id",
Usage: "label id",
},
},
}, flags.AllDefaultFlags...),
}
func runLabelDelete(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runLabelDelete(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
_, err := login.Client().DeleteLabel(owner, repo, ctx.Int64("id"))
if err != nil {
log.Fatal(err)
}
return nil
_, err := ctx.Login.Client().DeleteLabel(ctx.Owner, ctx.Repo, ctx.Int64("id"))
return err
}

View File

@ -1,14 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package labels
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/task"
@ -18,10 +15,11 @@ import (
// CmdLabelsList represents a sub command of labels to list labels
var CmdLabelsList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List labels",
Description: "List labels",
ArgsUsage: " ", // command does not accept arguments
Action: RunLabelsList,
Flags: append([]cli.Flag{
&cli.BoolFlag{
@ -35,18 +33,22 @@ var CmdLabelsList = cli.Command{
}
// RunLabelsList list labels.
func RunLabelsList(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func RunLabelsList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
labels, _, err := login.Client().ListRepoLabels(owner, repo, gitea.ListLabelsOptions{ListOptions: flags.GetListOptions(ctx)})
client := ctx.Login.Client()
labels, _, err := client.ListRepoLabels(ctx.Owner, ctx.Repo, gitea.ListLabelsOptions{
ListOptions: ctx.GetListOptions(),
})
if err != nil {
log.Fatal(err)
return err
}
if ctx.IsSet("save") {
return task.LabelsExport(labels, ctx.String("save"))
}
print.LabelsList(labels, flags.GlobalOutputValue)
print.LabelsList(labels, ctx.Output)
return nil
}

View File

@ -1,14 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package labels
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
@ -19,8 +16,9 @@ var CmdLabelUpdate = cli.Command{
Name: "update",
Usage: "Update a label",
Description: `Update a label`,
ArgsUsage: " ", // command does not accept arguments
Action: runLabelUpdate,
Flags: []cli.Flag{
Flags: append([]cli.Flag{
&cli.IntFlag{
Name: "id",
Usage: "label id",
@ -37,11 +35,12 @@ var CmdLabelUpdate = cli.Command{
Name: "description",
Usage: "label description",
},
},
}, flags.AllDefaultFlags...),
}
func runLabelUpdate(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runLabelUpdate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
id := ctx.Int64("id")
var pName, pColor, pDescription *string
@ -61,14 +60,14 @@ func runLabelUpdate(ctx *cli.Context) error {
}
var err error
_, _, err = login.Client().EditLabel(owner, repo, id, gitea.EditLabelOption{
_, _, err = ctx.Login.Client().EditLabel(ctx.Owner, ctx.Repo, id, gitea.EditLabelOption{
Name: pName,
Color: pColor,
Description: pDescription,
})
if err != nil {
log.Fatal(err)
return err
}
return nil

View File

@ -1,13 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/cmd/login"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/print"
@ -19,6 +17,7 @@ import (
var CmdLogin = cli.Command{
Name: "logins",
Aliases: []string{"login"},
Category: catSetup,
Usage: "Log in to a Gitea server",
Description: `Log in to a Gitea server`,
ArgsUsage: "[<login name>]",
@ -29,6 +28,7 @@ var CmdLogin = cli.Command{
&login.CmdLoginEdit,
&login.CmdLoginDelete,
&login.CmdLoginSetDefault,
&login.CmdLoginHelper,
},
}
@ -46,6 +46,6 @@ func runLoginDetail(name string) error {
return nil
}
print.LoginDetails(l, flags.GlobalOutputValue)
print.LoginDetails(l)
return nil
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package login
@ -16,6 +15,7 @@ var CmdLoginAdd = cli.Command{
Name: "add",
Usage: "Add a Gitea login",
Description: `Add a Gitea login, without args it will create one interactively`,
ArgsUsage: " ", // command does not accept arguments
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
@ -29,6 +29,11 @@ var CmdLoginAdd = cli.Command{
EnvVars: []string{"GITEA_SERVER_URL"},
Usage: "Server URL",
},
&cli.BoolFlag{
Name: "no-version-check",
Aliases: []string{"nv"},
Usage: "Do not check version of Gitea instance",
},
&cli.StringFlag{
Name: "token",
Aliases: []string{"t"},
@ -49,16 +54,41 @@ var CmdLoginAdd = cli.Command{
EnvVars: []string{"GITEA_SERVER_PASSWORD"},
Usage: "Password for basic auth (will create token)",
},
&cli.StringFlag{
Name: "otp",
EnvVars: []string{"GITEA_SERVER_OTP"},
Usage: "OTP token for auth, if necessary",
},
&cli.StringFlag{
Name: "scopes",
EnvVars: []string{"GITEA_SCOPES"},
Usage: "Token scopes to add when creating a new token, separated by a comma",
},
&cli.StringFlag{
Name: "ssh-key",
Aliases: []string{"s"},
Usage: "Path to a SSH key to use, overrides auto-discovery",
Usage: "Path to a SSH key/certificate to use, overrides auto-discovery",
},
&cli.BoolFlag{
Name: "insecure",
Aliases: []string{"i"},
Usage: "Disable TLS verification",
},
&cli.StringFlag{
Name: "ssh-agent-principal",
Aliases: []string{"c"},
Usage: "Use SSH certificate with specified principal to login (needs a running ssh-agent with certificate loaded)",
},
&cli.StringFlag{
Name: "ssh-agent-key",
Aliases: []string{"a"},
Usage: "Use SSH public key or SSH fingerprint to login (needs a running ssh-agent with ssh key loaded)",
},
&cli.BoolFlag{
Name: "helper",
Aliases: []string{"j"},
Usage: "Add helper",
},
},
Action: runLoginAdd,
}
@ -69,13 +99,26 @@ func runLoginAdd(ctx *cli.Context) error {
return interact.CreateLogin()
}
sshAgent := false
if ctx.String("ssh-agent-key") != "" || ctx.String("ssh-agent-principal") != "" {
sshAgent = true
}
// else use args to add login
return task.CreateLogin(
ctx.String("name"),
ctx.String("token"),
ctx.String("user"),
ctx.String("password"),
ctx.String("otp"),
ctx.String("scopes"),
ctx.String("ssh-key"),
ctx.String("url"),
ctx.Bool("insecure"))
ctx.String("ssh-agent-principal"),
ctx.String("ssh-agent-key"),
ctx.Bool("insecure"),
sshAgent,
!ctx.Bool("no-version-check"),
ctx.Bool("helper"),
)
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package login

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package login

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package login
@ -15,8 +14,10 @@ import (
// CmdLoginEdit represents to login a gitea server.
var CmdLoginEdit = cli.Command{
Name: "edit",
Aliases: []string{"e"},
Usage: "Edit Gitea logins",
Description: `Edit Gitea logins`,
ArgsUsage: " ", // command does not accept arguments
Action: runLoginEdit,
Flags: []cli.Flag{&flags.OutputFlag},
}

112
cmd/login/helper.go Normal file
View File

@ -0,0 +1,112 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package login
import (
"bufio"
"fmt"
"log"
"net/url"
"os"
"strings"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/task"
"github.com/urfave/cli/v2"
)
// CmdLoginHelper represents to login a gitea helper.
var CmdLoginHelper = cli.Command{
Name: "helper",
Aliases: []string{"git-credential"},
Usage: "Git helper",
Description: `Git helper`,
Hidden: true,
Subcommands: []*cli.Command{
{
Name: "store",
Description: "Command drops",
Aliases: []string{"erase"},
Action: func(ctx *cli.Context) error {
return nil
},
},
{
Name: "setup",
Description: "Setup helper to tea authenticate",
Action: func(ctx *cli.Context) error {
logins, err := config.GetLogins()
if err != nil {
return err
}
for _, login := range logins {
added, err := task.SetupHelper(login)
if err != nil {
return err
} else if added {
fmt.Printf("Added \"%s\"\n", login.Name)
} else {
fmt.Printf("\"%s\" has already been added!\n", login.Name)
}
}
return nil
},
},
{
Name: "get",
Description: "Get token to auth",
Action: func(cmd *cli.Context) error {
wants := map[string]string{}
s := bufio.NewScanner(os.Stdin)
for s.Scan() {
line := s.Text()
if line == "" {
break
}
parts := strings.SplitN(line, "=", 2)
if len(parts) < 2 {
continue
}
key, value := parts[0], parts[1]
if key == "url" {
u, err := url.Parse(value)
if err != nil {
return err
}
wants["protocol"] = u.Scheme
wants["host"] = u.Host
wants["path"] = u.Path
wants["username"] = u.User.Username()
wants["password"], _ = u.User.Password()
} else {
wants[key] = value
}
}
if len(wants["host"]) == 0 {
log.Fatal("Require hostname")
} else if len(wants["protocol"]) == 0 {
wants["protocol"] = "http"
}
userConfig := config.GetLoginByHost(wants["host"])
if len(userConfig.Token) == 0 {
log.Fatal("User no set")
}
host, err := url.Parse(userConfig.URL)
if err != nil {
return err
}
_, err = fmt.Fprintf(os.Stdout, "protocol=%s\nhost=%s\nusername=%s\npassword=%s\n", host.Scheme, host.Host, userConfig.User, userConfig.Token)
if err != nil {
return err
}
return nil
},
},
},
}

View File

@ -1,12 +1,9 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package login
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/print"
@ -16,21 +13,21 @@ import (
// CmdLoginList represents to login a gitea server.
var CmdLoginList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List Gitea logins",
Description: `List Gitea logins`,
ArgsUsage: " ", // command does not accept arguments
Action: RunLoginList,
Flags: []cli.Flag{&flags.OutputFlag},
}
// RunLoginList list all logins
func RunLoginList(_ *cli.Context) error {
func RunLoginList(cmd *cli.Context) error {
logins, err := config.GetLogins()
if err != nil {
log.Fatal(err)
return err
}
print.LoginsList(logins, flags.GlobalOutputValue)
print.LoginsList(logins, cmd.String("output"))
return nil
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
@ -13,6 +12,7 @@ import (
// CmdLogout represents to logout a gitea server.
var CmdLogout = cli.Command{
Name: "logout",
Category: catSetup,
Usage: "Log out from a Gitea server",
Description: `Log out from a Gitea server`,
ArgsUsage: "<login name>",

View File

@ -1,13 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/cmd/milestones"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"github.com/urfave/cli/v2"
@ -17,6 +15,7 @@ import (
var CmdMilestones = cli.Command{
Name: "milestones",
Aliases: []string{"milestone", "ms"},
Category: catEntities,
Usage: "List and create milestones",
Description: `List and create milestones`,
ArgsUsage: "[<milestone name>]",
@ -29,21 +28,22 @@ var CmdMilestones = cli.Command{
&milestones.CmdMilestonesReopen,
&milestones.CmdMilestonesIssues,
},
Flags: flags.AllDefaultFlags,
Flags: milestones.CmdMilestonesList.Flags,
}
func runMilestones(ctx *cli.Context) error {
if ctx.Args().Len() == 1 {
return runMilestoneDetail(ctx.Args().First())
return runMilestoneDetail(ctx, ctx.Args().First())
}
return milestones.RunMilestonesList(ctx)
}
func runMilestoneDetail(name string) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runMilestoneDetail(cmd *cli.Context, name string) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
milestone, _, err := client.GetMilestoneByName(owner, repo, name)
milestone, _, err := client.GetMilestoneByName(ctx.Owner, ctx.Repo, name)
if err != nil {
return err
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package milestones
@ -13,9 +12,9 @@ import (
// CmdMilestonesClose represents a sub command of milestones to close an milestone
var CmdMilestonesClose = cli.Command{
Name: "close",
Usage: "Change state of an milestone to 'closed'",
Description: `Change state of an milestone to 'closed'`,
ArgsUsage: "<milestone name>",
Usage: "Change state of one or more milestones to 'closed'",
Description: `Change state of one or more milestones to 'closed'`,
ArgsUsage: "<milestone name> [<milestone name>...]",
Action: func(ctx *cli.Context) error {
if ctx.Bool("force") {
return deleteMilestone(ctx)

View File

@ -1,26 +1,28 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package milestones
import (
"fmt"
"log"
"time"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/task"
"code.gitea.io/sdk/gitea"
"github.com/araddon/dateparse"
"github.com/urfave/cli/v2"
)
// CmdMilestonesCreate represents a sub command of milestones to create milestone
var CmdMilestonesCreate = cli.Command{
Name: "create",
Aliases: []string{"c"},
Usage: "Create an milestone on repository",
Description: `Create an milestone on repository`,
ArgsUsage: " ", // command does not accept arguments
Action: runMilestonesCreate,
Flags: append([]cli.Flag{
&cli.StringFlag{
@ -33,6 +35,11 @@ var CmdMilestonesCreate = cli.Command{
Aliases: []string{"d"},
Usage: "milestone description to create",
},
&cli.StringFlag{
Name: "deadline",
Aliases: []string{"expires", "x"},
Usage: "set milestone deadline (default is no due date)",
},
&cli.StringFlag{
Name: "state",
Usage: "set milestone state (default is open)",
@ -41,13 +48,17 @@ var CmdMilestonesCreate = cli.Command{
}, flags.AllDefaultFlags...),
}
func runMilestonesCreate(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runMilestonesCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
title := ctx.String("title")
if len(title) == 0 {
fmt.Printf("Title is required\n")
return nil
date := ctx.String("deadline")
deadline := &time.Time{}
if date != "" {
t, err := dateparse.ParseAny(date)
if err != nil {
return err
}
deadline = &t
}
state := gitea.StateOpen
@ -55,15 +66,17 @@ func runMilestonesCreate(ctx *cli.Context) error {
state = gitea.StateClosed
}
mile, _, err := login.Client().CreateMilestone(owner, repo, gitea.CreateMilestoneOption{
Title: title,
Description: ctx.String("description"),
State: state,
})
if err != nil {
log.Fatal(err)
if ctx.NumFlags() == 0 {
return interact.CreateMilestone(ctx.Login, ctx.Owner, ctx.Repo)
}
print.MilestoneDetails(mile)
return nil
return task.CreateMilestone(
ctx.Login,
ctx.Owner,
ctx.Repo,
ctx.String("title"),
ctx.String("description"),
deadline,
state,
)
}

View File

@ -1,12 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package milestones
import (
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"github.com/urfave/cli/v2"
)
@ -22,10 +21,11 @@ var CmdMilestonesDelete = cli.Command{
Flags: flags.AllDefaultFlags,
}
func deleteMilestone(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func deleteMilestone(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
_, err := client.DeleteMilestoneByName(owner, repo, ctx.Args().First())
_, err := client.DeleteMilestoneByName(ctx.Owner, ctx.Repo, ctx.Args().First())
return err
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package milestones
@ -8,7 +7,7 @@ import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
@ -16,6 +15,10 @@ import (
"github.com/urfave/cli/v2"
)
var msIssuesFieldsFlag = flags.FieldsFlag(print.IssueFields, []string{
"index", "kind", "title", "state", "updated", "labels",
})
// CmdMilestonesIssues represents a sub command of milestones to manage issue/pull of an milestone
var CmdMilestonesIssues = cli.Command{
Name: "issues",
@ -40,6 +43,7 @@ var CmdMilestonesIssues = cli.Command{
},
&flags.PaginationPageFlag,
&flags.PaginationLimitFlag,
msIssuesFieldsFlag,
}, flags.AllDefaultFlags...),
}
@ -65,9 +69,10 @@ var CmdMilestoneRemoveIssue = cli.Command{
Flags: flags.AllDefaultFlags,
}
func runMilestoneIssueList(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runMilestoneIssueList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
state := gitea.StateOpen
switch ctx.String("state") {
@ -91,13 +96,13 @@ func runMilestoneIssueList(ctx *cli.Context) error {
milestone := ctx.Args().First()
// make sure milestone exist
_, _, err := client.GetMilestoneByName(owner, repo, milestone)
_, _, err := client.GetMilestoneByName(ctx.Owner, ctx.Repo, milestone)
if err != nil {
return err
}
issues, _, err := client.ListRepoIssues(owner, repo, gitea.ListIssueOption{
ListOptions: flags.GetListOptions(ctx),
issues, _, err := client.ListRepoIssues(ctx.Owner, ctx.Repo, gitea.ListIssueOption{
ListOptions: ctx.GetListOptions(),
Milestones: []string{milestone},
Type: kind,
State: state,
@ -106,13 +111,18 @@ func runMilestoneIssueList(ctx *cli.Context) error {
return err
}
print.IssuesPullsList(issues, flags.GlobalOutputValue)
fields, err := msIssuesFieldsFlag.GetValues(cmd)
if err != nil {
return err
}
print.IssuesPullsList(issues, ctx.Output, fields)
return nil
}
func runMilestoneIssueAdd(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runMilestoneIssueAdd(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
if ctx.Args().Len() != 2 {
return fmt.Errorf("need two arguments")
}
@ -125,20 +135,21 @@ func runMilestoneIssueAdd(ctx *cli.Context) error {
}
// make sure milestone exist
mile, _, err := client.GetMilestoneByName(owner, repo, mileName)
mile, _, err := client.GetMilestoneByName(ctx.Owner, ctx.Repo, mileName)
if err != nil {
return err
}
_, _, err = client.EditIssue(owner, repo, idx, gitea.EditIssueOption{
_, _, err = client.EditIssue(ctx.Owner, ctx.Repo, idx, gitea.EditIssueOption{
Milestone: &mile.ID,
})
return err
}
func runMilestoneIssueRemove(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runMilestoneIssueRemove(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
if ctx.Args().Len() != 2 {
return fmt.Errorf("need two arguments")
}
@ -150,7 +161,7 @@ func runMilestoneIssueRemove(ctx *cli.Context) error {
return err
}
issue, _, err := client.GetIssue(owner, repo, idx)
issue, _, err := client.GetIssue(ctx.Owner, ctx.Repo, idx)
if err != nil {
return err
}
@ -164,7 +175,7 @@ func runMilestoneIssueRemove(ctx *cli.Context) error {
}
zero := int64(0)
_, _, err = client.EditIssue(owner, repo, idx, gitea.EditIssueOption{
_, _, err = client.EditIssue(ctx.Owner, ctx.Repo, idx, gitea.EditIssueOption{
Milestone: &zero,
})
return err

View File

@ -1,28 +1,31 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package milestones
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
var fieldsFlag = flags.FieldsFlag(print.MilestoneFields, []string{
"title", "items", "duedate",
})
// CmdMilestonesList represents a sub command of milestones to list milestones
var CmdMilestonesList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List milestones of the repository",
Description: `List milestones of the repository`,
ArgsUsage: " ", // command does not accept arguments
Action: RunMilestonesList,
Flags: append([]cli.Flag{
fieldsFlag,
&cli.StringFlag{
Name: "state",
Usage: "Filter by milestone state (all|open|closed)",
@ -34,26 +37,36 @@ var CmdMilestonesList = cli.Command{
}
// RunMilestonesList list milestones
func RunMilestonesList(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func RunMilestonesList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
fields, err := fieldsFlag.GetValues(cmd)
if err != nil {
return err
}
state := gitea.StateOpen
switch ctx.String("state") {
case "all":
state = gitea.StateAll
if !cmd.IsSet("fields") { // add to default fields
fields = append(fields, "state")
}
case "closed":
state = gitea.StateClosed
}
milestones, _, err := login.Client().ListRepoMilestones(owner, repo, gitea.ListMilestoneOption{
ListOptions: flags.GetListOptions(ctx),
client := ctx.Login.Client()
milestones, _, err := client.ListRepoMilestones(ctx.Owner, ctx.Repo, gitea.ListMilestoneOption{
ListOptions: ctx.GetListOptions(),
State: state,
})
if err != nil {
log.Fatal(err)
return err
}
print.MilestonesList(milestones, flags.GlobalOutputValue, state)
print.MilestonesList(milestones, ctx.Output, fields)
return nil
}

View File

@ -1,12 +1,14 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package milestones
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
@ -16,27 +18,43 @@ import (
var CmdMilestonesReopen = cli.Command{
Name: "reopen",
Aliases: []string{"open"},
Usage: "Change state of an milestone to 'open'",
Description: `Change state of an milestone to 'open'`,
ArgsUsage: "<milestone name>",
Usage: "Change state of one or more milestones to 'open'",
Description: `Change state of one or more milestones to 'open'`,
ArgsUsage: "<milestone name> [<milestone name> ...]",
Action: func(ctx *cli.Context) error {
return editMilestoneStatus(ctx, false)
},
Flags: flags.AllDefaultFlags,
}
func editMilestoneStatus(ctx *cli.Context, close bool) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func editMilestoneStatus(cmd *cli.Context, close bool) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() == 0 {
return fmt.Errorf(ctx.Command.ArgsUsage)
}
state := gitea.StateOpen
if close {
state = gitea.StateClosed
}
_, _, err := client.EditMilestoneByName(owner, repo, ctx.Args().First(), gitea.EditMilestoneOption{
State: &state,
Title: ctx.Args().First(),
})
return err
client := ctx.Login.Client()
for _, ms := range ctx.Args().Slice() {
opts := gitea.EditMilestoneOption{
State: &state,
Title: ms,
}
milestone, _, err := client.EditMilestoneByName(ctx.Owner, ctx.Repo, ms, opts)
if err != nil {
return err
}
if ctx.Args().Len() > 1 {
fmt.Printf("%s/milestone/%d\n", ctx.GetRemoteRepoHTMLURL(), milestone.ID)
} else {
print.MilestoneDetails(milestone)
}
}
return nil
}

View File

@ -1,82 +1,28 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"log"
"code.gitea.io/tea/cmd/notifications"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdNotifications is the main command to operate with notifications
var CmdNotifications = cli.Command{
Name: "notifications",
Aliases: []string{"notification", "notif"},
Aliases: []string{"notification", "n"},
Category: catHelpers,
Usage: "Show notifications",
Description: "Show notifications, by default based of the current repo and unread one",
Action: runNotifications,
Flags: append([]cli.Flag{
&cli.BoolFlag{
Name: "all",
Aliases: []string{"a"},
Usage: "show all notifications of related gitea instance",
},
&cli.BoolFlag{
Name: "read",
Aliases: []string{"rd"},
Usage: "show read notifications instead unread",
},
&cli.BoolFlag{
Name: "pinned",
Aliases: []string{"pd"},
Usage: "show pinned notifications instead unread",
},
&flags.PaginationPageFlag,
&flags.PaginationLimitFlag,
}, flags.AllDefaultFlags...),
}
func runNotifications(ctx *cli.Context) error {
var news []*gitea.NotificationThread
var err error
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
listOpts := flags.GetListOptions(ctx)
if listOpts.Page == 0 {
listOpts.Page = 1
}
var status []gitea.NotifyStatus
if ctx.Bool("read") {
status = []gitea.NotifyStatus{gitea.NotifyStatusRead}
}
if ctx.Bool("pinned") {
status = append(status, gitea.NotifyStatusPinned)
}
if ctx.Bool("all") {
news, _, err = login.Client().ListNotifications(gitea.ListNotificationOptions{
ListOptions: listOpts,
Status: status,
})
} else {
news, _, err = login.Client().ListRepoNotifications(owner, repo, gitea.ListNotificationOptions{
ListOptions: listOpts,
Status: status,
})
}
if err != nil {
log.Fatal(err)
}
print.NotificationsList(news, flags.GlobalOutputValue, ctx.Bool("all"))
return nil
Description: "Show notifications, by default based on the current repo if available",
Action: notifications.RunNotificationsList,
Subcommands: []*cli.Command{
&notifications.CmdNotificationsList,
&notifications.CmdNotificationsMarkRead,
&notifications.CmdNotificationsMarkUnread,
&notifications.CmdNotificationsMarkPinned,
&notifications.CmdNotificationsUnpin,
},
Flags: notifications.CmdNotificationsList.Flags,
}

106
cmd/notifications/list.go Normal file
View File

@ -0,0 +1,106 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package notifications
import (
"log"
"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 notifyFieldsFlag = flags.FieldsFlag(print.NotificationFields, []string{
"id", "status", "index", "type", "state", "title",
})
var notifyTypeFlag = flags.NewCsvFlag("types", "subject types to filter by", []string{"t"},
[]string{"issue", "pull", "repository", "commit"}, nil)
// CmdNotificationsList represents a sub command of notifications to list notifications
var CmdNotificationsList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Usage: "List notifications",
Description: `List notifications`,
ArgsUsage: " ", // command does not accept arguments
Action: RunNotificationsList,
Flags: append([]cli.Flag{
notifyFieldsFlag,
notifyTypeFlag,
}, flags.NotificationFlags...),
}
// RunNotificationsList list notifications
func RunNotificationsList(ctx *cli.Context) error {
var states []gitea.NotifyStatus
statesStr, err := flags.NotificationStateFlag.GetValues(ctx)
if err != nil {
return err
}
for _, s := range statesStr {
states = append(states, gitea.NotifyStatus(s))
}
var types []gitea.NotifySubjectType
typesStr, err := notifyTypeFlag.GetValues(ctx)
if err != nil {
return err
}
for _, t := range typesStr {
types = append(types, gitea.NotifySubjectType(t))
}
return listNotifications(ctx, states, types)
}
// listNotifications will get the notifications based on status and subject type
func listNotifications(cmd *cli.Context, status []gitea.NotifyStatus, subjects []gitea.NotifySubjectType) error {
var news []*gitea.NotificationThread
var err error
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
all := ctx.Bool("mine")
// This enforces pagination (see https://github.com/go-gitea/gitea/issues/16733)
listOpts := ctx.GetListOptions()
if listOpts.Page == 0 {
listOpts.Page = 1
}
fields, err := notifyFieldsFlag.GetValues(cmd)
if err != nil {
return err
}
if all {
// add repository to the default fields
if !cmd.IsSet("fields") {
fields = append(fields, "repository")
}
news, _, err = client.ListNotifications(gitea.ListNotificationOptions{
ListOptions: listOpts,
Status: status,
SubjectTypes: subjects,
})
} else {
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
news, _, err = client.ListRepoNotifications(ctx.Owner, ctx.Repo, gitea.ListNotificationOptions{
ListOptions: listOpts,
Status: status,
SubjectTypes: subjects,
})
}
if err != nil {
log.Fatal(err)
}
print.NotificationsList(news, ctx.Output, fields)
return nil
}

View File

@ -0,0 +1,138 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package notifications
import (
"fmt"
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
)
// CmdNotificationsMarkRead represents a sub command of notifications to list read notifications
var CmdNotificationsMarkRead = cli.Command{
Name: "read",
Aliases: []string{"r"},
Usage: "Mark all filtered or a specific notification as read",
Description: "Mark all filtered or a specific notification as read",
ArgsUsage: "[all | <notification id>]",
Flags: flags.NotificationFlags,
Action: func(ctx *cli.Context) error {
cmd := context.InitCommand(ctx)
filter, err := flags.NotificationStateFlag.GetValues(ctx)
if err != nil {
return err
}
if !cmd.IsSet(flags.NotificationStateFlag.Name) {
filter = []string{string(gitea.NotifyStatusUnread)}
}
return markNotificationAs(cmd, filter, gitea.NotifyStatusRead)
},
}
// CmdNotificationsMarkUnread will mark notifications as unread.
var CmdNotificationsMarkUnread = cli.Command{
Name: "unread",
Aliases: []string{"u"},
Usage: "Mark all filtered or a specific notification as unread",
Description: "Mark all filtered or a specific notification as unread",
ArgsUsage: "[all | <notification id>]",
Flags: flags.NotificationFlags,
Action: func(ctx *cli.Context) error {
cmd := context.InitCommand(ctx)
filter, err := flags.NotificationStateFlag.GetValues(ctx)
if err != nil {
return err
}
if !cmd.IsSet(flags.NotificationStateFlag.Name) {
filter = []string{string(gitea.NotifyStatusRead)}
}
return markNotificationAs(cmd, filter, gitea.NotifyStatusUnread)
},
}
// CmdNotificationsMarkPinned will mark notifications as unread.
var CmdNotificationsMarkPinned = cli.Command{
Name: "pin",
Aliases: []string{"p"},
Usage: "Mark all filtered or a specific notification as pinned",
Description: "Mark all filtered or a specific notification as pinned",
ArgsUsage: "[all | <notification id>]",
Flags: flags.NotificationFlags,
Action: func(ctx *cli.Context) error {
cmd := context.InitCommand(ctx)
filter, err := flags.NotificationStateFlag.GetValues(ctx)
if err != nil {
return err
}
if !cmd.IsSet(flags.NotificationStateFlag.Name) {
filter = []string{string(gitea.NotifyStatusUnread)}
}
return markNotificationAs(cmd, filter, gitea.NotifyStatusPinned)
},
}
// CmdNotificationsUnpin will mark pinned notifications as unread.
var CmdNotificationsUnpin = cli.Command{
Name: "unpin",
Usage: "Unpin all pinned or a specific notification",
Description: "Marks all pinned or a specific notification as read",
ArgsUsage: "[all | <notification id>]",
Flags: flags.NotificationFlags,
Action: func(ctx *cli.Context) error {
cmd := context.InitCommand(ctx)
filter := []string{string(gitea.NotifyStatusPinned)}
// NOTE: we implicitly mark it as read, to match web UI semantics. marking as unread might be more useful?
return markNotificationAs(cmd, filter, gitea.NotifyStatusRead)
},
}
func markNotificationAs(cmd *context.TeaContext, filterStates []string, targetState gitea.NotifyStatus) (err error) {
client := cmd.Login.Client()
subject := cmd.Args().First()
allRepos := cmd.Bool("mine")
states := []gitea.NotifyStatus{}
for _, s := range filterStates {
states = append(states, gitea.NotifyStatus(s))
}
switch subject {
case "", "all":
opts := gitea.MarkNotificationOptions{Status: states, ToStatus: targetState}
if allRepos {
_, _, err = client.ReadNotifications(opts)
} else {
cmd.Ensure(context.CtxRequirement{RemoteRepo: true})
_, _, err = client.ReadRepoNotifications(cmd.Owner, cmd.Repo, opts)
}
// TODO: print all affected notification subject URLs
// (not supported by API currently, https://github.com/go-gitea/gitea/issues/16797)
default:
id, err := utils.ArgToIndex(subject)
if err != nil {
return err
}
_, _, err = client.ReadNotification(id, targetState)
if err != nil {
return err
}
n, _, err := client.GetNotification(id)
if err != nil {
return err
}
// FIXME: this is an API URL, we want to display a web ui link..
fmt.Println(n.Subject.URL)
return nil
}
return err
}

View File

@ -1,16 +1,14 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"log"
"path"
"strings"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
local_git "code.gitea.io/tea/modules/git"
"github.com/skratchdot/open-golang/open"
@ -20,14 +18,17 @@ import (
// CmdOpen represents a sub command of issues to open issue on the web browser
var CmdOpen = cli.Command{
Name: "open",
Usage: "Open something of the repository on web browser",
Description: `Open something of the repository on web browser`,
Aliases: []string{"o"},
Category: catHelpers,
Usage: "Open something of the repository in web browser",
Description: `Open something of the repository in web browser`,
Action: runOpen,
Flags: append([]cli.Flag{}, flags.LoginRepoFlags...),
}
func runOpen(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runOpen(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
var suffix string
number := ctx.Args().Get(0)
@ -41,12 +42,11 @@ func runOpen(ctx *cli.Context) error {
case strings.EqualFold(number, "commits"):
repo, err := local_git.RepoForWorkdir()
if err != nil {
log.Fatal(err)
return err
}
b, err := repo.Head()
if err != nil {
log.Fatal(err)
return nil
return err
}
name := b.Name()
switch {
@ -73,11 +73,5 @@ func runOpen(ctx *cli.Context) error {
suffix = number
}
u := path.Join(login.URL, owner, repo, suffix)
err := open.Run(u)
if err != nil {
log.Fatal(err)
}
return nil
return open.Run(path.Join(ctx.GetRemoteRepoHTMLURL(), suffix))
}

View File

@ -1,13 +1,12 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"log"
"code.gitea.io/tea/cmd/organizations"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"github.com/urfave/cli/v2"
)
@ -16,25 +15,33 @@ import (
var CmdOrgs = cli.Command{
Name: "organizations",
Aliases: []string{"organization", "org"},
Category: catEntities,
Usage: "List, create, delete organizations",
Description: "Show organization details",
ArgsUsage: "[<organization>]",
Action: runOrganizations,
Subcommands: []*cli.Command{
&organizations.CmdOrganizationList,
&organizations.CmdOrganizationCreate,
&organizations.CmdOrganizationDelete,
},
Flags: organizations.CmdOrganizationList.Flags,
}
func runOrganizations(ctx *cli.Context) error {
func runOrganizations(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
if ctx.Args().Len() == 1 {
return runOrganizationDetail(ctx.Args().First())
return runOrganizationDetail(ctx)
}
return organizations.RunOrganizationList(ctx)
return organizations.RunOrganizationList(cmd)
}
func runOrganizationDetail(path string) error {
func runOrganizationDetail(ctx *context.TeaContext) error {
org, _, err := ctx.Login.Client().GetOrg(ctx.Args().First())
if err != nil {
return err
}
log.Fatal("Not yet implemented.")
print.OrganizationDetails(org)
return nil
}

View File

@ -0,0 +1,89 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package organizations
import (
"fmt"
"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"
)
// CmdOrganizationCreate represents a sub command of organizations to delete a given user organization
var CmdOrganizationCreate = cli.Command{
Name: "create",
Aliases: []string{"c"},
Usage: "Create an organization",
Description: "Create an organization",
Action: RunOrganizationCreate,
ArgsUsage: "<organization name>",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
},
&cli.StringFlag{
Name: "description",
Aliases: []string{"d"},
},
&cli.StringFlag{
Name: "website",
Aliases: []string{"w"},
},
&cli.StringFlag{
Name: "location",
Aliases: []string{"L"},
},
&cli.StringFlag{
Name: "visibility",
Aliases: []string{"v"},
},
&cli.BoolFlag{
Name: "repo-admins-can-change-team-access",
},
&flags.LoginFlag,
},
}
// RunOrganizationCreate sets up a new organization
func RunOrganizationCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
if ctx.Args().Len() < 1 {
return fmt.Errorf("You have to specify the organization name you want to create")
}
var visibility gitea.VisibleType
switch ctx.String("visibility") {
case "", "public":
visibility = gitea.VisibleTypePublic
case "private":
visibility = gitea.VisibleTypePrivate
case "limited":
visibility = gitea.VisibleTypeLimited
default:
return fmt.Errorf("unknown visibility '%s'", ctx.String("visibility"))
}
org, _, err := ctx.Login.Client().CreateOrg(gitea.CreateOrgOption{
Name: ctx.Args().First(),
// FullName: , // not really meaningful for orgs (not displayed in webui, use description instead?)
Description: ctx.String("description"),
Website: ctx.String("website"),
Location: ctx.String("location"),
RepoAdminChangeTeamAccess: ctx.Bool("repo-admins-can-change-team-access"),
Visibility: visibility,
})
if err != nil {
return err
}
print.OrganizationDetails(org)
return err
}

View File

@ -1,14 +1,13 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package organizations
import (
"log"
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"github.com/urfave/cli/v2"
)
@ -20,23 +19,25 @@ var CmdOrganizationDelete = cli.Command{
Description: "Delete users organizations",
ArgsUsage: "<organization name>",
Action: RunOrganizationDelete,
Flags: []cli.Flag{
&flags.LoginFlag,
&flags.RemoteFlag,
},
}
// RunOrganizationDelete delete user organization
func RunOrganizationDelete(ctx *cli.Context) error {
login, _, _ := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func RunOrganizationDelete(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := login.Client()
client := ctx.Login.Client()
if ctx.Args().Len() < 1 {
log.Fatal("You have to specify the organization name you want to delete.")
return nil
return fmt.Errorf("You have to specify the organization name you want to delete")
}
response, err := client.DeleteOrg(ctx.Args().First())
if response != nil && response.StatusCode == 404 {
log.Fatal("The given organization does not exist.")
return nil
return fmt.Errorf("The given organization does not exist")
}
return err

View File

@ -1,14 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package organizations
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
@ -17,10 +14,11 @@ import (
// CmdOrganizationList represents a sub command of organizations to list users organizations
var CmdOrganizationList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List Organizations",
Description: "List users organizations",
ArgsUsage: " ", // command does not accept arguments
Action: RunOrganizationList,
Flags: append([]cli.Flag{
&flags.PaginationPageFlag,
@ -29,17 +27,18 @@ var CmdOrganizationList = cli.Command{
}
// RunOrganizationList list user organizations
func RunOrganizationList(ctx *cli.Context) error {
login, _, _ := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func RunOrganizationList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
client := login.Client()
userOrganizations, _, err := client.ListUserOrgs(login.User, gitea.ListOrgsOptions{ListOptions: flags.GetListOptions(ctx)})
userOrganizations, _, err := client.ListUserOrgs(ctx.Login.User, gitea.ListOrgsOptions{
ListOptions: ctx.GetListOptions(),
})
if err != nil {
log.Fatal(err)
return err
}
print.OrganizationsList(userOrganizations, flags.GlobalOutputValue)
print.OrganizationsList(userOrganizations, ctx.Output)
return nil
}

View File

@ -1,17 +1,17 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/cmd/pulls"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
"code.gitea.io/tea/modules/workaround"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
@ -21,44 +21,75 @@ import (
var CmdPulls = cli.Command{
Name: "pulls",
Aliases: []string{"pull", "pr"},
Usage: "List, create, checkout and clean pull requests",
Description: `List, create, checkout and clean pull requests`,
Category: catEntities,
Usage: "Manage and checkout pull requests",
Description: `Lists PRs when called without argument. If PR index is provided, will show it in detail.`,
ArgsUsage: "[<pull index>]",
Action: runPulls,
Flags: flags.IssuePRFlags,
Flags: append([]cli.Flag{
&cli.BoolFlag{
Name: "comments",
Usage: "Whether to display comments (will prompt if not provided & run interactively)",
},
}, pulls.CmdPullsList.Flags...),
Subcommands: []*cli.Command{
&pulls.CmdPullsList,
&pulls.CmdPullsCheckout,
&pulls.CmdPullsClean,
&pulls.CmdPullsCreate,
&pulls.CmdPullsClose,
&pulls.CmdPullsReopen,
&pulls.CmdPullsReview,
&pulls.CmdPullsApprove,
&pulls.CmdPullsReject,
&pulls.CmdPullsMerge,
},
}
func runPulls(ctx *cli.Context) error {
if ctx.Args().Len() == 1 {
return runPullDetail(ctx.Args().First())
return runPullDetail(ctx, ctx.Args().First())
}
return pulls.RunPullsList(ctx)
}
func runPullDetail(index string) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runPullDetail(cmd *cli.Context, index string) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
idx, err := utils.ArgToIndex(index)
if err != nil {
return err
}
client := login.Client()
pr, _, err := client.GetPullRequest(owner, repo, idx)
client := ctx.Login.Client()
pr, _, err := client.GetPullRequest(ctx.Owner, ctx.Repo, idx)
if err != nil {
return err
}
if err := workaround.FixPullHeadSha(client, pr); err != nil {
return err
}
reviews, _, err := client.ListPullReviews(owner, repo, idx, gitea.ListPullReviewsOptions{})
reviews, _, err := client.ListPullReviews(ctx.Owner, ctx.Repo, idx, gitea.ListPullReviewsOptions{
ListOptions: gitea.ListOptions{Page: -1},
})
if err != nil {
fmt.Printf("error while loading reviews: %v\n", err)
}
print.PullDetails(pr, reviews)
ci, _, err := client.GetCombinedStatus(ctx.Owner, ctx.Repo, pr.Head.Sha)
if err != nil {
fmt.Printf("error while loading CI: %v\n", err)
}
print.PullDetails(pr, reviews, ci)
if pr.Comments > 0 {
err = interact.ShowCommentsMaybeInteractive(ctx, idx, pr.Comments)
if err != nil {
fmt.Printf("error loading comments: %v\n", err)
}
}
return nil
}

44
cmd/pulls/approve.go Normal file
View File

@ -0,0 +1,44 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pulls
import (
"fmt"
"strings"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/task"
"code.gitea.io/tea/modules/utils"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdPullsApprove approves a PR
var CmdPullsApprove = cli.Command{
Name: "approve",
Aliases: []string{"lgtm", "a"},
Usage: "Approve a pull request",
Description: "Approve a pull request",
ArgsUsage: "<pull index> [<comment>]",
Action: func(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() == 0 {
return fmt.Errorf("Must specify a PR index")
}
idx, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
return err
}
comment := strings.Join(ctx.Args().Tail(), " ")
return task.CreatePullReview(ctx, idx, gitea.ReviewStateApproved, comment, nil)
},
Flags: flags.AllDefaultFlags,
}

View File

@ -1,14 +1,13 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package pulls
import (
"log"
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/task"
"code.gitea.io/tea/modules/utils"
@ -19,22 +18,33 @@ import (
// CmdPullsCheckout is a command to locally checkout the given PR
var CmdPullsCheckout = cli.Command{
Name: "checkout",
Aliases: []string{"co"},
Usage: "Locally check out the given PR",
Description: `Locally check out the given PR`,
Action: runPullsCheckout,
ArgsUsage: "<pull index>",
Flags: flags.AllDefaultFlags,
Flags: append([]cli.Flag{
&cli.BoolFlag{
Name: "branch",
Aliases: []string{"b"},
Usage: "Create a local branch if it doesn't exist yet",
},
}, flags.AllDefaultFlags...),
}
func runPullsCheckout(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runPullsCheckout(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{
LocalRepo: true,
RemoteRepo: true,
})
if ctx.Args().Len() != 1 {
log.Fatal("Must specify a PR index")
return fmt.Errorf("Must specify a PR index")
}
idx, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
return err
}
return task.PullCheckout(login, owner, repo, idx, interact.PromptPassword)
return task.PullCheckout(ctx.Login, ctx.Owner, ctx.Repo, ctx.Bool("branch"), idx, interact.PromptPassword)
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package pulls
@ -8,7 +7,7 @@ import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/task"
"code.gitea.io/tea/modules/utils"
@ -31,8 +30,9 @@ var CmdPullsClean = cli.Command{
}, flags.AllDefaultFlags...),
}
func runPullsClean(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runPullsClean(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{LocalRepo: true})
if ctx.Args().Len() != 1 {
return fmt.Errorf("Must specify a PR index")
}
@ -42,5 +42,5 @@ func runPullsClean(ctx *cli.Context) error {
return err
}
return task.PullClean(login, owner, repo, idx, ctx.Bool("ignore-sha"), interact.PromptPassword)
return task.PullClean(ctx.Login, ctx.Owner, ctx.Repo, idx, ctx.Bool("ignore-sha"), interact.PromptPassword)
}

24
cmd/pulls/close.go Normal file
View File

@ -0,0 +1,24 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pulls
import (
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdPullsClose closes a given open pull request
var CmdPullsClose = cli.Command{
Name: "close",
Usage: "Change state of one or more pull requests to 'closed'",
Description: `Change state of one or more pull requests to 'closed'`,
ArgsUsage: "<pull index> [<pull index>...]",
Action: func(ctx *cli.Context) error {
var s = gitea.StateClosed
return editPullState(ctx, gitea.EditPullRequestOption{State: &s})
},
Flags: flags.AllDefaultFlags,
}

View File

@ -1,12 +1,11 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package pulls
import (
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/task"
@ -16,48 +15,48 @@ import (
// CmdPullsCreate creates a pull request
var CmdPullsCreate = cli.Command{
Name: "create",
Aliases: []string{"c"},
Usage: "Create a pull-request",
Description: "Create a pull-request",
Description: "Create a pull-request in the current repo",
Action: runPullsCreate,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "head",
Usage: "Set head branch (default is current one)",
Usage: "Branch name of the PR source (default is current one). To specify a different head repo, use <user>:<branch>",
},
&cli.StringFlag{
Name: "base",
Aliases: []string{"b"},
Usage: "Set base branch (default is default branch)",
Usage: "Branch name of the PR target (default is repos default branch)",
},
&cli.StringFlag{
Name: "title",
Aliases: []string{"t"},
Usage: "Set title of pull (default is head branch name)",
&cli.BoolFlag{
Name: "allow-maintainer-edits",
Aliases: []string{"edits"},
Usage: "Enable maintainers to push to the base branch of created pull",
Value: true,
},
&cli.StringFlag{
Name: "description",
Aliases: []string{"d"},
Usage: "Set body of new pull",
},
}, flags.AllDefaultFlags...),
}, flags.IssuePRCreateFlags...),
}
func runPullsCreate(ctx *cli.Context) error {
login, ownerArg, repoArg := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runPullsCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
// no args -> interactive mode
if ctx.NumFlags() == 0 {
return interact.CreatePull(login, ownerArg, repoArg)
return interact.CreatePull(ctx)
}
// else use args to create PR
opts, err := flags.GetIssuePRCreateFlags(ctx)
if err != nil {
return err
}
return task.CreatePull(
login,
ownerArg,
repoArg,
ctx,
ctx.String("base"),
ctx.String("head"),
ctx.String("title"),
ctx.String("description"),
ctx.Bool("allow-maintainer-edits"),
opts,
)
}

44
cmd/pulls/edit.go Normal file
View File

@ -0,0 +1,44 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pulls
import (
"fmt"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// editPullState abstracts the arg parsing to edit the given pull request
func editPullState(cmd *cli.Context, opts gitea.EditPullRequestOption) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() == 0 {
return fmt.Errorf("Please provide a Pull Request index")
}
indices, err := utils.ArgsToIndices(ctx.Args().Slice())
if err != nil {
return err
}
client := ctx.Login.Client()
for _, index := range indices {
pr, _, err := client.EditPullRequest(ctx.Owner, ctx.Repo, index, opts)
if err != nil {
return err
}
if len(indices) > 1 {
fmt.Println(pr.HTMLURL)
} else {
print.PullDetails(pr, nil, nil)
}
}
return nil
}

View File

@ -1,33 +1,36 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package pulls
import (
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
var pullFieldsFlag = flags.FieldsFlag(print.PullFields, []string{
"index", "title", "state", "author", "milestone", "updated", "labels",
})
// CmdPullsList represents a sub command of issues to list pulls
var CmdPullsList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List pull requests of the repository",
Description: `List pull requests of the repository`,
ArgsUsage: " ", // command does not accept arguments
Action: RunPullsList,
Flags: flags.IssuePRFlags,
Flags: append([]cli.Flag{pullFieldsFlag}, flags.PRListingFlags...),
}
// RunPullsList return list of pulls
func RunPullsList(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func RunPullsList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
state := gitea.StateOpen
switch ctx.String("state") {
@ -39,14 +42,19 @@ func RunPullsList(ctx *cli.Context) error {
state = gitea.StateClosed
}
prs, _, err := login.Client().ListRepoPullRequests(owner, repo, gitea.ListPullRequestsOptions{
prs, _, err := ctx.Login.Client().ListRepoPullRequests(ctx.Owner, ctx.Repo, gitea.ListPullRequestsOptions{
State: state,
})
if err != nil {
log.Fatal(err)
return err
}
print.PullsList(prs, flags.GlobalOutputValue)
fields, err := pullFieldsFlag.GetValues(cmd)
if err != nil {
return err
}
print.PullsList(prs, ctx.Output, fields)
return nil
}

62
cmd/pulls/merge.go Normal file
View File

@ -0,0 +1,62 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pulls
import (
"code.gitea.io/sdk/gitea"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/task"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
)
// CmdPullsMerge merges a PR
var CmdPullsMerge = cli.Command{
Name: "merge",
Aliases: []string{"m"},
Usage: "Merge a pull request",
Description: "Merge a pull request",
ArgsUsage: "<pull index>",
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "style",
Aliases: []string{"s"},
Usage: "Kind of merge to perform: merge, rebase, squash, rebase-merge",
Value: "merge",
},
&cli.StringFlag{
Name: "title",
Aliases: []string{"t"},
Usage: "Merge commit title",
},
&cli.StringFlag{
Name: "message",
Aliases: []string{"m"},
Usage: "Merge commit message",
},
}, flags.AllDefaultFlags...),
Action: func(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() != 1 {
// If no PR index is provided, try interactive mode
return interact.MergePull(ctx)
}
idx, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
return err
}
return task.PullMerge(ctx.Login, ctx.Owner, ctx.Repo, idx, gitea.MergePullRequestOption{
Style: gitea.MergeStyle(ctx.String("style")),
Title: ctx.String("title"),
Message: ctx.String("message"),
})
},
}

43
cmd/pulls/reject.go Normal file
View File

@ -0,0 +1,43 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pulls
import (
"fmt"
"strings"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/task"
"code.gitea.io/tea/modules/utils"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdPullsReject requests changes to a PR
var CmdPullsReject = cli.Command{
Name: "reject",
Usage: "Request changes to a pull request",
Description: "Request changes to a pull request",
ArgsUsage: "<pull index> <reason>",
Action: func(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() < 2 {
return fmt.Errorf("Must specify a PR index and comment")
}
idx, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
return err
}
comment := strings.Join(ctx.Args().Tail(), " ")
return task.CreatePullReview(ctx, idx, gitea.ReviewStateRequestChanges, comment, nil)
},
Flags: flags.AllDefaultFlags,
}

25
cmd/pulls/reopen.go Normal file
View File

@ -0,0 +1,25 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pulls
import (
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdPullsReopen reopens a given closed pull request
var CmdPullsReopen = cli.Command{
Name: "reopen",
Aliases: []string{"open"},
Usage: "Change state of one or more pull requests to 'open'",
Description: `Change state of one or more pull requests to 'open'`,
ArgsUsage: "<pull index> [<pull index>...]",
Action: func(ctx *cli.Context) error {
var s = gitea.StateOpen
return editPullState(ctx, gitea.EditPullRequestOption{State: &s})
},
Flags: flags.AllDefaultFlags,
}

39
cmd/pulls/review.go Normal file
View File

@ -0,0 +1,39 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pulls
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/interact"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
)
// CmdPullsReview starts an interactive review session
var CmdPullsReview = cli.Command{
Name: "review",
Usage: "Interactively review a pull request",
Description: "Interactively review a pull request",
ArgsUsage: "<pull index>",
Action: func(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() != 1 {
return fmt.Errorf("Must specify a PR index")
}
idx, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
return err
}
return interact.ReviewPull(ctx, idx)
},
Flags: flags.AllDefaultFlags,
}

View File

@ -1,6 +1,5 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
@ -15,15 +14,18 @@ import (
// ToDo: ReleaseDetails
var CmdReleases = cli.Command{
Name: "releases",
Aliases: []string{"release"},
Aliases: []string{"release", "r"},
Category: catEntities,
Usage: "Manage releases",
Description: "Manage releases",
ArgsUsage: " ", // command does not accept arguments
Action: releases.RunReleasesList,
Subcommands: []*cli.Command{
&releases.CmdReleaseList,
&releases.CmdReleaseCreate,
&releases.CmdReleaseDelete,
&releases.CmdReleaseEdit,
&CmdReleaseAttachments,
},
Flags: flags.AllDefaultFlags,
}

View File

@ -1,18 +1,16 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package releases
import (
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
@ -21,17 +19,19 @@ import (
// CmdReleaseCreate represents a sub command of Release to create release
var CmdReleaseCreate = cli.Command{
Name: "create",
Aliases: []string{"c"},
Usage: "Create a release",
Description: `Create a release`,
Description: `Create a release for a new or existing git tag`,
ArgsUsage: "[<tag>]",
Action: runReleaseCreate,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "tag",
Usage: "Tag name",
Usage: "Tag name. If the tag does not exist yet, it will be created by Gitea",
},
&cli.StringFlag{
Name: "target",
Usage: "Target refs, branch name or commit id",
Usage: "Target branch name or commit hash. Defaults to the default branch of the repo",
},
&cli.StringFlag{
Name: "title",
@ -56,16 +56,25 @@ var CmdReleaseCreate = cli.Command{
&cli.StringSliceFlag{
Name: "asset",
Aliases: []string{"a"},
Usage: "List of files to attach",
Usage: "Path to file attachment. Can be specified multiple times",
},
}, flags.AllDefaultFlags...),
}
func runReleaseCreate(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runReleaseCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
release, resp, err := login.Client().CreateRelease(owner, repo, gitea.CreateReleaseOption{
TagName: ctx.String("tag"),
tag := ctx.String("tag")
if cmd.Args().Present() {
if len(tag) != 0 {
return fmt.Errorf("ambiguous arguments: provide tagname via --tag or argument, but not both")
}
tag = cmd.Args().First()
}
release, resp, err := ctx.Login.Client().CreateRelease(ctx.Owner, ctx.Repo, gitea.CreateReleaseOption{
TagName: tag,
Target: ctx.String("target"),
Title: ctx.String("title"),
Note: ctx.String("note"),
@ -75,24 +84,23 @@ func runReleaseCreate(ctx *cli.Context) error {
if err != nil {
if resp != nil && resp.StatusCode == http.StatusConflict {
fmt.Println("error: There already is a release for this tag")
return nil
return fmt.Errorf("There already is a release for this tag")
}
log.Fatal(err)
return err
}
for _, asset := range ctx.StringSlice("asset") {
var file *os.File
if file, err = os.Open(asset); err != nil {
log.Fatal(err)
return err
}
filePath := filepath.Base(asset)
if _, _, err = login.Client().CreateReleaseAttachment(owner, repo, release.ID, file, filePath); err != nil {
if _, _, err = ctx.Login.Client().CreateReleaseAttachment(ctx.Owner, ctx.Repo, release.ID, file, filePath); err != nil {
file.Close()
log.Fatal(err)
return err
}
file.Close()

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package releases
@ -8,7 +7,7 @@ import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"github.com/urfave/cli/v2"
)
@ -16,9 +15,10 @@ import (
// CmdReleaseDelete represents a sub command of Release to delete a release
var CmdReleaseDelete = cli.Command{
Name: "delete",
Usage: "Delete a release",
Description: `Delete a release`,
ArgsUsage: "<release tag>",
Aliases: []string{"rm"},
Usage: "Delete one or more releases",
Description: `Delete one or more releases`,
ArgsUsage: "<release tag> [<release tag>...]",
Action: runReleaseDelete,
Flags: append([]cli.Flag{
&cli.BoolFlag{
@ -33,13 +33,13 @@ var CmdReleaseDelete = cli.Command{
}, flags.AllDefaultFlags...),
}
func runReleaseDelete(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runReleaseDelete(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
tag := ctx.Args().First()
if len(tag) == 0 {
fmt.Println("Release tag needed to delete")
if !ctx.Args().Present() {
fmt.Println("Release tag needed to edit")
return nil
}
@ -48,22 +48,20 @@ func runReleaseDelete(ctx *cli.Context) error {
return nil
}
release, err := getReleaseByTag(owner, repo, tag, client)
if err != nil {
return err
}
if release == nil {
return nil
}
for _, tag := range ctx.Args().Slice() {
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
if err != nil {
return err
}
_, err = client.DeleteRelease(ctx.Owner, ctx.Repo, release.ID)
if err != nil {
return err
}
_, err = client.DeleteRelease(owner, repo, release.ID)
if err != nil {
return err
}
if ctx.Bool("delete-tag") {
_, err = client.DeleteReleaseTag(owner, repo, tag)
return err
if ctx.Bool("delete-tag") {
_, err = client.DeleteTag(ctx.Owner, ctx.Repo, tag)
return err
}
}
return nil

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package releases
@ -9,7 +8,7 @@ import (
"strings"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
@ -18,9 +17,10 @@ import (
// CmdReleaseEdit represents a sub command of Release to edit releases
var CmdReleaseEdit = cli.Command{
Name: "edit",
Usage: "Edit a release",
Description: `Edit a release`,
ArgsUsage: "<release tag>",
Aliases: []string{"e"},
Usage: "Edit one or more releases",
Description: `Edit one or more releases`,
ArgsUsage: "<release tag> [<release tag>...]",
Action: runReleaseEdit,
Flags: append([]cli.Flag{
&cli.StringFlag{
@ -56,23 +56,10 @@ var CmdReleaseEdit = cli.Command{
}, flags.AllDefaultFlags...),
}
func runReleaseEdit(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
tag := ctx.Args().First()
if len(tag) == 0 {
fmt.Println("Release tag needed to edit")
return nil
}
release, err := getReleaseByTag(owner, repo, tag, client)
if err != nil {
return err
}
if release == nil {
return nil
}
func runReleaseEdit(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
var isDraft, isPre *bool
if ctx.IsSet("draft") {
@ -82,13 +69,28 @@ func runReleaseEdit(ctx *cli.Context) error {
isPre = gitea.OptionalBool(strings.ToLower(ctx.String("prerelease"))[:1] == "t")
}
_, _, err = client.EditRelease(owner, repo, release.ID, gitea.EditReleaseOption{
TagName: ctx.String("tag"),
Target: ctx.String("target"),
Title: ctx.String("title"),
Note: ctx.String("note"),
IsDraft: isDraft,
IsPrerelease: isPre,
})
return err
if !ctx.Args().Present() {
fmt.Println("Release tag needed to edit")
return nil
}
for _, tag := range ctx.Args().Slice() {
release, err := getReleaseByTag(ctx.Owner, ctx.Repo, tag, client)
if err != nil {
return err
}
_, _, err = client.EditRelease(ctx.Owner, ctx.Repo, release.ID, gitea.EditReleaseOption{
TagName: ctx.String("tag"),
Target: ctx.String("target"),
Title: ctx.String("title"),
Note: ctx.String("note"),
IsDraft: isDraft,
IsPrerelease: isPre,
})
if err != nil {
return err
}
}
return nil
}

View File

@ -1,15 +1,13 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package releases
import (
"fmt"
"log"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
@ -18,10 +16,11 @@ import (
// CmdReleaseList represents a sub command of Release to list releases
var CmdReleaseList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List Releases",
Description: "List Releases",
ArgsUsage: " ", // command does not accept arguments
Action: RunReleasesList,
Flags: append([]cli.Flag{
&flags.PaginationPageFlag,
@ -30,32 +29,35 @@ var CmdReleaseList = cli.Command{
}
// RunReleasesList list releases
func RunReleasesList(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func RunReleasesList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
releases, _, err := login.Client().ListReleases(owner, repo, gitea.ListReleasesOptions{ListOptions: flags.GetListOptions(ctx)})
releases, _, err := ctx.Login.Client().ListReleases(ctx.Owner, ctx.Repo, gitea.ListReleasesOptions{
ListOptions: ctx.GetListOptions(),
})
if err != nil {
log.Fatal(err)
return err
}
print.ReleasesList(releases, flags.GlobalOutputValue)
print.ReleasesList(releases, ctx.Output)
return nil
}
func getReleaseByTag(owner, repo, tag string, client *gitea.Client) (*gitea.Release, error) {
rl, _, err := client.ListReleases(owner, repo, gitea.ListReleasesOptions{})
rl, _, err := client.ListReleases(owner, repo, gitea.ListReleasesOptions{
ListOptions: gitea.ListOptions{Page: -1},
})
if err != nil {
return nil, err
}
if len(rl) == 0 {
fmt.Println("Repo does not have any release")
return nil, nil
return nil, fmt.Errorf("Repo does not have any release")
}
for _, r := range rl {
if r.TagName == tag {
return r, nil
}
}
fmt.Println("Release tag does not exist")
return nil, nil
return nil, fmt.Errorf("Release tag does not exist")
}

View File

@ -1,13 +1,11 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/cmd/repos"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
@ -19,6 +17,7 @@ import (
var CmdRepos = cli.Command{
Name: "repos",
Aliases: []string{"repo"},
Category: catEntities,
Usage: "Show repository details",
Description: "Show repository details",
ArgsUsage: "[<repo owner>/<repo name>]",
@ -27,26 +26,30 @@ var CmdRepos = cli.Command{
&repos.CmdReposList,
&repos.CmdReposSearch,
&repos.CmdRepoCreate,
&repos.CmdRepoCreateFromTemplate,
&repos.CmdRepoFork,
&repos.CmdRepoMigrate,
&repos.CmdRepoRm,
},
Flags: repos.CmdReposListFlags,
}
func runRepos(ctx *cli.Context) error {
if ctx.Args().Len() == 1 {
return runRepoDetail(ctx.Args().First())
return runRepoDetail(ctx, ctx.Args().First())
}
return repos.RunReposList(ctx)
}
func runRepoDetail(path string) error {
login, ownerFallback, _ := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
repoOwner, repoName := utils.GetOwnerAndRepo(path, ownerFallback)
func runRepoDetail(cmd *cli.Context, path string) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
repoOwner, repoName := utils.GetOwnerAndRepo(path, ctx.Owner)
repo, _, err := client.GetRepo(repoOwner, repoName)
if err != nil {
return err
}
topics, _, err := client.ListRepoTopics(repo.Owner.UserName, repo.Name, gitea.ListRepoTopicsOptions{})
topics, _, err := client.ListRepoTopics(repoOwner, repoName, gitea.ListRepoTopicsOptions{})
if err != nil {
return err
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package repos
@ -8,7 +7,7 @@ import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
@ -21,6 +20,7 @@ var CmdRepoCreate = cli.Command{
Aliases: []string{"c"},
Usage: "Create a repository",
Description: "Create a repository",
ArgsUsage: " ", // command does not accept arguments
Action: runRepoCreate,
Flags: append([]cli.Flag{
&cli.StringFlag{
@ -79,16 +79,39 @@ var CmdRepoCreate = cli.Command{
Required: false,
Usage: "use custom default branch (need --init)",
},
&cli.BoolFlag{
Name: "template",
Usage: "make repo a template repo",
},
&cli.StringFlag{
Name: "trustmodel",
Usage: "select trust model (committer,collaborator,collaborator+committer)",
},
}, flags.LoginOutputFlags...),
}
func runRepoCreate(ctx *cli.Context) error {
login, _, _ := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runRepoCreate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
var (
repo *gitea.Repository
err error
repo *gitea.Repository
err error
trustmodel gitea.TrustModel
)
if ctx.IsSet("trustmodel") {
switch ctx.String("trustmodel") {
case "committer":
trustmodel = gitea.TrustModelCommitter
case "collaborator":
trustmodel = gitea.TrustModelCollaborator
case "collaborator+committer":
trustmodel = gitea.TrustModelCollaboratorCommitter
default:
return fmt.Errorf("unknown trustmodel type '%s'", ctx.String("trustmodel"))
}
}
opts := gitea.CreateRepoOption{
Name: ctx.String("name"),
Description: ctx.String("description"),
@ -99,6 +122,8 @@ func runRepoCreate(ctx *cli.Context) error {
License: ctx.String("license"),
Readme: ctx.String("readme"),
DefaultBranch: ctx.String("branch"),
Template: ctx.Bool("template"),
TrustModel: trustmodel,
}
if len(ctx.String("owner")) != 0 {
repo, _, err = client.CreateOrgRepo(ctx.String("owner"), opts)

View File

@ -0,0 +1,120 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package repos
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/tea/modules/utils"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// CmdRepoCreateFromTemplate represents a sub command of repos to generate one from a template repo
var CmdRepoCreateFromTemplate = cli.Command{
Name: "create-from-template",
Aliases: []string{"ct"},
Usage: "Create a repository based on an existing template",
Description: "Create a repository based on an existing template",
Action: runRepoCreateFromTemplate,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "template",
Aliases: []string{"t"},
Required: true,
Usage: "source template to copy from",
},
&cli.StringFlag{
Name: "name",
Aliases: []string{"n"},
Required: true,
Usage: "name of new repo",
},
&cli.StringFlag{
Name: "owner",
Aliases: []string{"O"},
Usage: "name of repo owner",
},
&cli.BoolFlag{
Name: "private",
Usage: "make new repo private",
},
&cli.StringFlag{
Name: "description",
Aliases: []string{"desc"},
Usage: "add custom description to repo",
},
&cli.BoolFlag{
Name: "content",
Value: true,
Usage: "copy git content from template",
},
&cli.BoolFlag{
Name: "githooks",
Value: true,
Usage: "copy git hooks from template",
},
&cli.BoolFlag{
Name: "avatar",
Value: true,
Usage: "copy repo avatar from template",
},
&cli.BoolFlag{
Name: "labels",
Value: true,
Usage: "copy repo labels from template",
},
&cli.BoolFlag{
Name: "topics",
Value: true,
Usage: "copy topics from template",
},
&cli.BoolFlag{
Name: "webhooks",
Usage: "copy webhooks from template",
},
}, flags.LoginOutputFlags...),
}
func runRepoCreateFromTemplate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
templateOwner, templateRepo := utils.GetOwnerAndRepo(ctx.String("template"), ctx.Login.User)
owner := ctx.Login.User
if ctx.IsSet("owner") {
owner = ctx.String("owner")
}
opts := gitea.CreateRepoFromTemplateOption{
Name: ctx.String("name"),
Owner: owner,
Description: ctx.String("description"),
Private: ctx.Bool("private"),
GitContent: ctx.Bool("content"),
GitHooks: ctx.Bool("githooks"),
Avatar: ctx.Bool("avatar"),
Labels: ctx.Bool("labels"),
Topics: ctx.Bool("topics"),
Webhooks: ctx.Bool("webhooks"),
}
repo, _, err := client.CreateRepoFromTemplate(templateOwner, templateRepo, opts)
if err != nil {
return err
}
topics, _, err := client.ListRepoTopics(repo.Owner.UserName, repo.Name, gitea.ListRepoTopicsOptions{})
if err != nil {
return err
}
print.RepoDetails(repo, topics)
fmt.Printf("%s\n", repo.HTMLURL)
return nil
}

85
cmd/repos/delete.go Normal file
View File

@ -0,0 +1,85 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package repos
import (
"fmt"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/context"
"github.com/AlecAivazis/survey/v2"
"github.com/urfave/cli/v2"
)
// CmdRepoRm represents a sub command of repos to delete an existing repo
var CmdRepoRm = cli.Command{
Name: "delete",
Aliases: []string{"rm"},
Usage: "Delete an existing repository",
Description: "Removes a repository from Create a repository from an existing repo",
ArgsUsage: " ", // command does not accept arguments
Action: runRepoDelete,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "name",
Aliases: []string{""},
Required: true,
Usage: "name of the repo",
},
&cli.StringFlag{
Name: "owner",
Aliases: []string{"O"},
Required: false,
Usage: "owner of the repo",
},
&cli.BoolFlag{
Name: "force",
Aliases: []string{"f"},
Required: false,
Value: false,
Usage: "Force the deletion and don't ask for confirmation",
},
}, flags.LoginOutputFlags...),
}
func runRepoDelete(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
var owner string
if ctx.IsSet("owner") {
owner = ctx.String("owner")
} else {
owner = ctx.Login.User
}
repoName := ctx.String("name")
repoSlug := fmt.Sprintf("%s/%s", owner, repoName)
if !ctx.Bool("force") {
var enteredRepoSlug string
promptRepoName := &survey.Input{
Message: fmt.Sprintf("Confirm the deletion of the repository '%s' by typing its name: ", repoSlug),
}
if err := survey.AskOne(promptRepoName, &enteredRepoSlug, survey.WithValidator(survey.Required)); err != nil {
return err
}
if enteredRepoSlug != repoSlug {
return fmt.Errorf("Entered wrong repository name '%s', expected '%s'", enteredRepoSlug, repoSlug)
}
}
_, err := client.DeleteRepo(owner, repoName)
if err != nil {
return err
}
fmt.Printf("Successfully deleted %s/%s\n", owner, repoName)
return nil
}

View File

@ -1,33 +1,15 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package repos
import (
"fmt"
"strings"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
// printFieldsFlag provides a selection of fields to print
var printFieldsFlag = cli.StringFlag{
Name: "fields",
Aliases: []string{"f"},
Usage: fmt.Sprintf(`Comma-separated list of fields to print. Available values:
%s
`, strings.Join(print.RepoFields, ",")),
Value: "owner,name,type,ssh",
}
func getFields(ctx *cli.Context) []string {
return strings.Split(ctx.String("fields"), ",")
}
var typeFilterFlag = cli.StringFlag{
Name: "type",
Aliases: []string{"T"},

58
cmd/repos/fork.go Normal file
View File

@ -0,0 +1,58 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package repos
import (
"fmt"
"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"
)
// CmdRepoFork represents a sub command of repos to fork an existing repo
var CmdRepoFork = cli.Command{
Name: "fork",
Aliases: []string{"f"},
Usage: "Fork an existing repository",
Description: "Create a repository from an existing repo",
ArgsUsage: " ", // command does not accept arguments
Action: runRepoFork,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "owner",
Aliases: []string{"O"},
Usage: "name of fork's owner, defaults to current user",
},
}, flags.LoginRepoFlags...),
}
func runRepoFork(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
opts := gitea.CreateForkOption{}
if ctx.IsSet("owner") {
owner := ctx.String("owner")
opts.Organization = &owner
}
repo, _, err := client.CreateFork(ctx.Owner, ctx.Repo, opts)
if err != nil {
return err
}
topics, _, err := client.ListRepoTopics(repo.Owner.UserName, repo.Name, gitea.ListRepoTopicsOptions{})
if err != nil {
return err
}
print.RepoDetails(repo, topics)
fmt.Printf("%s\n", repo.HTMLURL)
return nil
}

View File

@ -1,18 +1,21 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package repos
import (
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
"github.com/urfave/cli/v2"
)
var repoFieldsFlag = flags.FieldsFlag(print.RepoFields, []string{
"owner", "name", "type", "ssh",
})
// CmdReposListFlags contains all flags needed for repo listing
var CmdReposListFlags = append([]cli.Flag{
&cli.BoolFlag{
@ -27,7 +30,7 @@ var CmdReposListFlags = append([]cli.Flag{
Required: false,
Usage: "List your starred repos instead",
},
&printFieldsFlag,
repoFieldsFlag,
&typeFilterFlag,
&flags.PaginationPageFlag,
&flags.PaginationLimitFlag,
@ -35,8 +38,8 @@ var CmdReposListFlags = append([]cli.Flag{
// CmdReposList represents a sub command of repos to list them
var CmdReposList = cli.Command{
Name: "ls",
Aliases: []string{"list"},
Name: "list",
Aliases: []string{"ls"},
Usage: "List repositories you have access to",
Description: "List repositories you have access to",
Action: RunReposList,
@ -44,11 +47,11 @@ var CmdReposList = cli.Command{
}
// RunReposList list repositories
func RunReposList(ctx *cli.Context) error {
login, _, _ := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func RunReposList(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
typeFilter, err := getTypeFilter(ctx)
typeFilter, err := getTypeFilter(cmd)
if err != nil {
return err
}
@ -60,14 +63,14 @@ func RunReposList(ctx *cli.Context) error {
return err
}
rps, _, err = client.SearchRepos(gitea.SearchRepoOptions{
ListOptions: flags.GetListOptions(ctx),
ListOptions: ctx.GetListOptions(),
StarredByUserID: user.ID,
})
} else if ctx.Bool("watched") {
rps, _, err = client.GetMyWatchedRepos() // TODO: this does not expose pagination..
} else {
rps, _, err = client.ListMyRepos(gitea.ListReposOptions{
ListOptions: flags.GetListOptions(ctx),
ListOptions: ctx.GetListOptions(),
})
}
@ -80,7 +83,12 @@ func RunReposList(ctx *cli.Context) error {
reposFiltered = filterReposByType(rps, typeFilter)
}
print.ReposList(reposFiltered, flags.GlobalOutputValue, getFields(ctx))
fields, err := repoFieldsFlag.GetValues(cmd)
if err != nil {
return err
}
print.ReposList(reposFiltered, ctx.Output, fields)
return nil
}

168
cmd/repos/migrate.go Normal file
View File

@ -0,0 +1,168 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package repos
import (
"fmt"
"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"
)
// CmdRepoMigrate represents a sub command of repos to migrate one
var CmdRepoMigrate = cli.Command{
Name: "migrate",
Aliases: []string{"m"},
Usage: "Migrate a repository",
Description: "Migrate a repository and or mirror it.",
ArgsUsage: " ", // command does not accept arguments
Action: runRepoMigrate,
Flags: append([]cli.Flag{
&cli.StringFlag{
Name: "name",
Usage: "Name of the repository",
Required: true,
},
&cli.StringFlag{
Name: "owner",
Usage: "Owner of the repository",
Required: true,
},
&cli.StringFlag{
Name: "clone-url",
Usage: "Clone URL of the repository",
Required: true,
},
&cli.StringFlag{
Name: "service",
Usage: string("Service to migrate from. Supported services are: " + gitea.GitServicePlain +
", " + gitea.GitServiceGitea + ", " + gitea.GitServiceGitlab + ", " + gitea.GitServiceGogs),
Required: true,
},
&cli.BoolFlag{
Name: "mirror",
Usage: "Mirror the repository",
},
&cli.BoolFlag{
Name: "private",
Usage: "Make the repository private",
},
&cli.BoolFlag{
Name: "template",
Usage: "Make the repository a template",
},
&cli.BoolFlag{
Name: "wiki",
Usage: "Copy the wiki",
},
&cli.BoolFlag{
Name: "issues",
Usage: "Copy the issues",
},
&cli.BoolFlag{
Name: "pull-requests",
Usage: "Copy the pull requests",
},
&cli.BoolFlag{
Name: "releases",
Usage: "Copy the releases",
},
&cli.BoolFlag{
Name: "milestones",
Usage: "Copy the milestones",
},
&cli.StringFlag{
Name: "mirror-interval",
Usage: "Interval to mirror the repository.",
},
&cli.BoolFlag{
Name: "lfs",
Usage: "Copy the LFS objects",
},
&cli.StringFlag{
Name: "lfs-endpoint",
Usage: "LFS endpoint to use",
},
&cli.StringFlag{
Name: "auth-user",
Usage: "Username to use for authentication.",
},
&cli.StringFlag{
Name: "auth-password",
Usage: "Password to use for authentication.",
},
&cli.StringFlag{
Name: "auth-token",
Usage: "Token to use for authentication.",
},
}, flags.LoginOutputFlags...),
}
func runRepoMigrate(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
var (
repo *gitea.Repository
err error
service gitea.GitServiceType
)
if ctx.IsSet("service") {
switch ctx.String("service") {
case "git":
service = gitea.GitServicePlain
case "gitea":
service = gitea.GitServiceGitea
case "gitlab":
service = gitea.GitServiceGitlab
case "gogs":
service = gitea.GitServiceGogs
case "github":
service = gitea.GitServiceGithub
default:
return fmt.Errorf("unknown git service type '%s'", ctx.String("service"))
}
}
opts := gitea.MigrateRepoOption{
RepoName: ctx.String("name"),
RepoOwner: ctx.String("owner"),
CloneAddr: ctx.String("clone-url"),
Service: service,
AuthUsername: ctx.String("auth-user"),
AuthPassword: ctx.String("auth-password"),
AuthToken: ctx.String("auth-token"),
Mirror: ctx.Bool("mirror"),
Private: ctx.Bool("private"),
Description: ctx.String("description"),
Wiki: ctx.Bool("wiki"),
Milestones: ctx.Bool("milestones"),
Labels: ctx.Bool("labels"),
Issues: ctx.Bool("issues"),
PullRequests: ctx.Bool("pull-requests"),
Releases: ctx.Bool("releases"),
MirrorInterval: ctx.String("mirror-interval"),
LFS: ctx.Bool("lfs"),
LFSEndpoint: ctx.String("lfs-endpoint"),
}
repo, _, err = client.MigrateRepo(opts)
if err != nil {
return err
}
topics, _, err := client.ListRepoTopics(repo.Owner.UserName, repo.Name, gitea.ListRepoTopicsOptions{})
if err != nil {
return err
}
print.RepoDetails(repo, topics)
fmt.Printf("%s\n", repo.HTMLURL)
return nil
}

View File

@ -1,15 +1,14 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package repos
import (
"log"
"fmt"
"strings"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/print"
"code.gitea.io/sdk/gitea"
@ -50,15 +49,15 @@ var CmdReposSearch = cli.Command{
Required: false,
Usage: "Filter archived repos (true|false)",
},
&printFieldsFlag,
repoFieldsFlag,
&flags.PaginationPageFlag,
&flags.PaginationLimitFlag,
}, flags.LoginOutputFlags...),
}
func runReposSearch(ctx *cli.Context) error {
login, _, _ := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runReposSearch(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
client := ctx.Login.Client()
var ownerID int64
if ctx.IsSet("owner") {
@ -67,7 +66,7 @@ func runReposSearch(ctx *cli.Context) error {
if err != nil {
// HACK: the client does not return a response on 404, so we can't check res.StatusCode
if err.Error() != "404 Not Found" {
log.Fatal("could not find owner: ", err)
return fmt.Errorf("Could not find owner: %s", err)
}
// if owner is no org, its a user
@ -93,7 +92,7 @@ func runReposSearch(ctx *cli.Context) error {
isPrivate = &private
}
mode, err := getTypeFilter(ctx)
mode, err := getTypeFilter(cmd)
if err != nil {
return err
}
@ -109,7 +108,7 @@ func runReposSearch(ctx *cli.Context) error {
}
rps, _, err := client.SearchRepos(gitea.SearchRepoOptions{
ListOptions: flags.GetListOptions(ctx),
ListOptions: ctx.GetListOptions(),
OwnerID: ownerID,
IsPrivate: isPrivate,
IsArchived: isArchived,
@ -123,6 +122,10 @@ func runReposSearch(ctx *cli.Context) error {
return err
}
print.ReposList(rps, flags.GlobalOutputValue, getFields(ctx))
fields, err := repoFieldsFlag.GetValues(cmd)
if err != nil {
return err
}
print.ReposList(rps, ctx.Output, fields)
return nil
}

View File

@ -1,6 +1,5 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
@ -11,22 +10,20 @@ import (
// CmdTrackedTimes represents the command to operate repositories' times.
var CmdTrackedTimes = cli.Command{
Name: "times",
Aliases: []string{"time"},
Usage: "Operate on tracked times of a repository's issues & pulls",
Name: "times",
Aliases: []string{"time", "t"},
Category: catEntities,
Usage: "Operate on tracked times of a repository's issues & pulls",
Description: `Operate on tracked times of a repository's issues & pulls.
Depending on your permissions on the repository, only your own tracked
times might be listed.`,
ArgsUsage: "[username | #issue]",
Action: runTrackedTimes,
Action: times.RunTimesList,
Subcommands: []*cli.Command{
&times.CmdTrackedTimesAdd,
&times.CmdTrackedTimesDelete,
&times.CmdTrackedTimesReset,
&times.CmdTrackedTimesList,
},
}
func runTrackedTimes(ctx *cli.Context) error {
return times.RunTimesList(ctx)
Flags: times.CmdTrackedTimesList.Flags,
}

View File

@ -1,17 +1,15 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package times
import (
"fmt"
"log"
"strings"
"time"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/utils"
"code.gitea.io/sdk/gitea"
@ -21,6 +19,7 @@ import (
// CmdTrackedTimesAdd represents a sub command of times to add time to an issue
var CmdTrackedTimesAdd = cli.Command{
Name: "add",
Aliases: []string{"a"},
Usage: "Track spent time on an issue",
UsageText: "tea times add <issue> <duration>",
Description: `Track spent time on an issue
@ -31,8 +30,9 @@ var CmdTrackedTimesAdd = cli.Command{
Flags: flags.LoginRepoFlags,
}
func runTrackedTimesAdd(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
func runTrackedTimesAdd(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
if ctx.Args().Len() < 2 {
return fmt.Errorf("No issue or duration specified.\nUsage:\t%s", ctx.Command.UsageText)
@ -40,20 +40,16 @@ func runTrackedTimesAdd(ctx *cli.Context) error {
issue, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
log.Fatal(err)
return err
}
duration, err := time.ParseDuration(strings.Join(ctx.Args().Tail(), ""))
if err != nil {
log.Fatal(err)
return err
}
_, _, err = login.Client().AddTime(owner, repo, issue, gitea.AddTimeOption{
_, _, err = ctx.Login.Client().AddTime(ctx.Owner, ctx.Repo, issue, gitea.AddTimeOption{
Time: int64(duration.Seconds()),
})
if err != nil {
log.Fatal(err)
}
return nil
return err
}

View File

@ -1,16 +1,14 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package times
import (
"fmt"
"log"
"strconv"
"code.gitea.io/tea/cmd/flags"
"code.gitea.io/tea/modules/config"
"code.gitea.io/tea/modules/context"
"code.gitea.io/tea/modules/utils"
"github.com/urfave/cli/v2"
@ -26,9 +24,10 @@ var CmdTrackedTimesDelete = cli.Command{
Flags: flags.LoginRepoFlags,
}
func runTrackedTimesDelete(ctx *cli.Context) error {
login, owner, repo := config.InitCommand(flags.GlobalRepoValue, flags.GlobalLoginValue, flags.GlobalRemoteValue)
client := login.Client()
func runTrackedTimesDelete(cmd *cli.Context) error {
ctx := context.InitCommand(cmd)
ctx.Ensure(context.CtxRequirement{RemoteRepo: true})
client := ctx.Login.Client()
if ctx.Args().Len() < 2 {
return fmt.Errorf("No issue or time ID specified.\nUsage:\t%s", ctx.Command.UsageText)
@ -36,18 +35,14 @@ func runTrackedTimesDelete(ctx *cli.Context) error {
issue, err := utils.ArgToIndex(ctx.Args().First())
if err != nil {
log.Fatal(err)
return err
}
timeID, err := strconv.ParseInt(ctx.Args().Get(1), 10, 64)
if err != nil {
log.Fatal(err)
return err
}
_, err = client.DeleteTime(owner, repo, issue, timeID)
if err != nil {
log.Fatal(err)
}
return nil
_, err = client.DeleteTime(ctx.Owner, ctx.Repo, issue, timeID)
return err
}

Some files were not shown because too many files have changed in this diff Show More