mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-05 18:58:43 +02:00
Merge branch 'main' into lunny/add_reply_code_review
This commit is contained in:
+13
-8
@@ -16,10 +16,15 @@ import (
|
|||||||
|
|
||||||
// CmdLoginAdd represents to login a gitea server.
|
// CmdLoginAdd represents to login a gitea server.
|
||||||
var CmdLoginAdd = cli.Command{
|
var CmdLoginAdd = cli.Command{
|
||||||
Name: "add",
|
Name: "add",
|
||||||
Usage: "Add a Gitea login",
|
Usage: "Add a Gitea login",
|
||||||
Description: `Add a Gitea login, without args it will create one interactively`,
|
Description: `Add a Gitea login, without args it will create one interactively.
|
||||||
ArgsUsage: " ", // command does not accept arguments
|
|
||||||
|
By default tea only stores the token for its own API use. Pass --git-credentials
|
||||||
|
to also register tea as a git credential helper for the login's URL, so that
|
||||||
|
'git push' and 'git clone' over HTTPS authenticate silently using the stored
|
||||||
|
token. Equivalent to running 'tea login helper setup' afterwards.`,
|
||||||
|
ArgsUsage: " ", // command does not accept arguments
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "name",
|
Name: "name",
|
||||||
@@ -89,9 +94,9 @@ var CmdLoginAdd = cli.Command{
|
|||||||
Usage: "Use SSH public key or SSH fingerprint to login (needs a running ssh-agent with ssh key loaded)",
|
Usage: "Use SSH public key or SSH fingerprint to login (needs a running ssh-agent with ssh key loaded)",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "helper",
|
Name: "git-credentials",
|
||||||
Aliases: []string{"j"},
|
Aliases: []string{"helper", "j"},
|
||||||
Usage: "Add helper",
|
Usage: "Register tea as a git credential helper for this login's URL, so 'git push' and 'git clone' over HTTPS authenticate silently using the stored token",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "oauth",
|
Name: "oauth",
|
||||||
@@ -161,6 +166,6 @@ func runLoginAdd(requestCtx context.Context, cmd *cli.Command) error {
|
|||||||
cmd.Bool("insecure"),
|
cmd.Bool("insecure"),
|
||||||
sshAgent,
|
sshAgent,
|
||||||
!cmd.Bool("no-version-check"),
|
!cmd.Bool("no-version-check"),
|
||||||
cmd.Bool("helper"),
|
cmd.Bool("git-credentials"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-8
@@ -19,23 +19,31 @@ import (
|
|||||||
|
|
||||||
// CmdLoginHelper represents to login a gitea helper.
|
// CmdLoginHelper represents to login a gitea helper.
|
||||||
var CmdLoginHelper = cli.Command{
|
var CmdLoginHelper = cli.Command{
|
||||||
Name: "helper",
|
Name: "helper",
|
||||||
Aliases: []string{"git-credential"},
|
Aliases: []string{"git-credential"},
|
||||||
Usage: "Git helper",
|
Usage: "Act as a git credential helper for stored Gitea logins",
|
||||||
Description: `Git helper`,
|
Description: `Speaks git's credential helper protocol so that HTTPS push and clone
|
||||||
Hidden: true,
|
operations against your configured Gitea instances authenticate silently
|
||||||
|
using the tokens tea already stores.
|
||||||
|
|
||||||
|
Typical use is automatic: 'tea login add --git-credentials' (or 'tea login
|
||||||
|
helper setup' for existing logins) registers '!tea login helper' as a
|
||||||
|
credential helper in ~/.gitconfig. Git then invokes the 'get' subcommand
|
||||||
|
when it needs credentials for a configured host.`,
|
||||||
Commands: []*cli.Command{
|
Commands: []*cli.Command{
|
||||||
{
|
{
|
||||||
Name: "store",
|
Name: "store",
|
||||||
Description: "Command drops",
|
|
||||||
Aliases: []string{"erase"},
|
Aliases: []string{"erase"},
|
||||||
|
Usage: "No-op (git credential protocol store/erase)",
|
||||||
|
Description: "No-op invoked by git on credential store/erase; tea persists credentials only in its own config",
|
||||||
Action: func(requestCtx context.Context, _ *cli.Command) error {
|
Action: func(requestCtx context.Context, _ *cli.Command) error {
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "setup",
|
Name: "setup",
|
||||||
Description: "Setup helper to tea authenticate",
|
Usage: "Register tea as a git credential helper for every configured login",
|
||||||
|
Description: "Register tea as a git credential helper in ~/.gitconfig for every configured login",
|
||||||
Action: func(requestCtx context.Context, _ *cli.Command) error {
|
Action: func(requestCtx context.Context, _ *cli.Command) error {
|
||||||
logins, err := config.GetLogins()
|
logins, err := config.GetLogins()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -56,7 +64,8 @@ var CmdLoginHelper = cli.Command{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "get",
|
Name: "get",
|
||||||
Description: "Get token to auth",
|
Usage: "Return the stored token for a URL (git credential protocol)",
|
||||||
|
Description: "Return the stored token for a given URL in git's credential helper protocol (called by git, reads request from stdin)",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "login",
|
Name: "login",
|
||||||
|
|||||||
+19
-1
@@ -41,7 +41,7 @@ Add a Gitea login
|
|||||||
|
|
||||||
**--client-id**="": OAuth client ID (for use with --oauth)
|
**--client-id**="": OAuth client ID (for use with --oauth)
|
||||||
|
|
||||||
**--helper, -j**: Add helper
|
**--git-credentials, --helper, -j**: Register tea as a git credential helper for this login's URL, so 'git push' and 'git clone' over HTTPS authenticate silently using the stored token
|
||||||
|
|
||||||
**--insecure, -i**: Disable TLS verification
|
**--insecure, -i**: Disable TLS verification
|
||||||
|
|
||||||
@@ -87,6 +87,24 @@ Get or Set Default Login
|
|||||||
|
|
||||||
**--output, -o**="": Output format. (simple, table, csv, tsv, yaml, json)
|
**--output, -o**="": Output format. (simple, table, csv, tsv, yaml, json)
|
||||||
|
|
||||||
|
### helper, git-credential
|
||||||
|
|
||||||
|
Act as a git credential helper for stored Gitea logins
|
||||||
|
|
||||||
|
#### store, erase
|
||||||
|
|
||||||
|
No-op (git credential protocol store/erase)
|
||||||
|
|
||||||
|
#### setup
|
||||||
|
|
||||||
|
Register tea as a git credential helper for every configured login
|
||||||
|
|
||||||
|
#### get
|
||||||
|
|
||||||
|
Return the stored token for a URL (git credential protocol)
|
||||||
|
|
||||||
|
**--login, -l**="": Use a specific login
|
||||||
|
|
||||||
### oauth-refresh
|
### oauth-refresh
|
||||||
|
|
||||||
Refresh an OAuth token
|
Refresh an OAuth token
|
||||||
|
|||||||
@@ -59,9 +59,12 @@ func PullDetails(pr *gitea.PullRequest, reviews []*gitea.PullReview, ciStatus *g
|
|||||||
}
|
}
|
||||||
|
|
||||||
if pr.State == gitea.StateOpen {
|
if pr.State == gitea.StateOpen {
|
||||||
if pr.Mergeable {
|
switch {
|
||||||
|
case pr.Mergeable:
|
||||||
out += "- No Conflicts\n"
|
out += "- No Conflicts\n"
|
||||||
} else {
|
case pr.Draft:
|
||||||
|
out += "- Draft (not mergeable until marked ready)\n"
|
||||||
|
default:
|
||||||
out += "- **Conflicting files**\n"
|
out += "- **Conflicting files**\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ func CreateLogin(ctx stdctx.Context, name, token, user, passwd, otp, scopes, ssh
|
|||||||
if _, err := SetupHelper(login); err != nil {
|
if _, err := SetupHelper(login); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("Tip: pass --git-credentials (or run 'tea login helper setup') to authenticate 'git push' and 'git clone' over HTTPS with this token.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user