Skip to content

Migrate to urfave v3 #34510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open

Conversation

TheFox0x7
Copy link
Contributor

@TheFox0x7 TheFox0x7 commented May 20, 2025

migrate cli to urfave v3

add more cli tests

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 20, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/internal modifies/dependencies labels May 20, 2025
@TheFox0x7
Copy link
Contributor Author

For future: I don't mind you/someone else fixing/editing stuff but a heads up would be nice - especially on a WIP where half of it is hacks to get tests to pass.

Either way thanks for some cleanups on this.

@wxiaoguang
Copy link
Contributor

Sorry, I saw it had no progress for long time, and we had some discussions about the strange "config" behavior in discord, so I just tried to fix the problems. Will ask ahead next time.

@TheFox0x7
Copy link
Contributor Author

No problem, I appreciate your effort regardless. :)

@TheFox0x7 TheFox0x7 marked this pull request as ready for review June 7, 2025 22:34
docs, err := ctx.App.ToMarkdown()
if ctx.Bool("man") {
docs, err = ctx.App.ToMan()
func runDocs(_ context.Context, cmd *cli.Command) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reviewers: Double check if the docs are correct as the generation is weird, but it might not have the same issue as with tea due to custom help.

Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much, and there are new cool tests

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jun 8, 2025
@wxiaoguang wxiaoguang added this to the 1.25.0 milestone Jun 8, 2025
@wxiaoguang wxiaoguang added type/refactoring Existing code has been cleaned up. There should be no new functionality. and removed type/refactoring Existing code has been cleaned up. There should be no new functionality. labels Jun 8, 2025
@@ -0,0 +1,111 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Copyright 2023 The Gitea Authors. All rights reserved.
// Copyright 2025 The Gitea Authors. All rights reserved.

}
if err != nil {
log.Fatalf("Failed to generate private key: %v", err)
// log.Fatalf("Failed to generate private key: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not delete this line?

}

var notBefore time.Time
if startDate := c.String("start-date"); startDate != "" {
notBefore, err = time.Parse("Jan 2 15:04:05 2006", startDate)
if err != nil {
log.Fatalf("Failed to parse creation date: %v", err)
// log.Fatalf("Failed to parse creation date: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as previous one.

@@ -129,7 +141,8 @@ func runCert(c *cli.Context) error {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
log.Fatalf("Failed to generate serial number: %v", err)
// log.Fatalf("Failed to generate serial number: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as previous one.

@@ -162,34 +175,41 @@ func runCert(c *cli.Context) error {

derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, publicKey(priv), priv)
if err != nil {
log.Fatalf("Failed to create certificate: %v", err)
// log.Fatalf("Failed to create certificate: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as previous one.

for _, a := range args {
// fmt.Println("checking:", a, "it's set:", c.IsSet(a), "and it's:", c.String(a), "but value:", c.Value(a))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trace line?

Usage: "Generate self-signed certificate",
Description: `Generate a self-signed X.509 certificate for a TLS server.
// cmdCert represents the available cert sub-command.
func cmdCert() *cli.Command {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a function instead of a variable here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 1 This PR needs approval from one additional maintainer to be merged. modifies/cli PR changes something on the CLI, i.e. gitea doctor or gitea admin modifies/dependencies modifies/go Pull requests that update Go code modifies/internal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants