Skip to content

Commit 82ea557

Browse files
authored
Fix stderr usages (#26477)
1 parent ca74b07 commit 82ea557

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

cmd/admin_user_create.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package cmd
66
import (
77
"errors"
88
"fmt"
9-
"os"
109

1110
auth_model "code.gitea.io/gitea/models/auth"
1211
user_model "code.gitea.io/gitea/models/user"
@@ -87,7 +86,7 @@ func runCreateUser(c *cli.Context) error {
8786
username = c.String("username")
8887
} else {
8988
username = c.String("name")
90-
fmt.Fprintf(os.Stderr, "--name flag is deprecated. Use --username instead.\n")
89+
_, _ = fmt.Fprintf(c.App.ErrWriter, "--name flag is deprecated. Use --username instead.\n")
9190
}
9291

9392
ctx, cancel := installSignals()

models/migrations/migrations.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ package migrations
77
import (
88
"context"
99
"fmt"
10-
"os"
1110

1211
"code.gitea.io/gitea/models/migrations/v1_10"
1312
"code.gitea.io/gitea/models/migrations/v1_11"
@@ -608,8 +607,7 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
608607
if !setting.IsProd {
609608
msg += fmt.Sprintf("\nIf you are in development and really know what you're doing, you can force changing the migration version by executing: UPDATE version SET version=%d WHERE id=1;", minDBVersion+len(migrations))
610609
}
611-
_, _ = fmt.Fprintln(os.Stderr, msg)
612-
log.Fatal(msg)
610+
log.Fatal("Migration Error: %s", msg)
613611
return nil
614612
}
615613

services/gitdiff/gitdiff.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"html/template"
1414
"io"
1515
"net/url"
16-
"os"
1716
"sort"
1817
"strings"
1918
"time"
@@ -1152,14 +1151,15 @@ func GetDiff(gitRepo *git.Repository, opts *DiffOptions, files ...string) (*Diff
11521151
}()
11531152

11541153
go func() {
1154+
stderr := &bytes.Buffer{}
11551155
cmdDiff.SetDescription(fmt.Sprintf("GetDiffRange [repo_path: %s]", repoPath))
11561156
if err := cmdDiff.Run(&git.RunOpts{
11571157
Timeout: time.Duration(setting.Git.Timeout.Default) * time.Second,
11581158
Dir: repoPath,
1159-
Stderr: os.Stderr,
11601159
Stdout: writer,
1160+
Stderr: stderr,
11611161
}); err != nil {
1162-
log.Error("error during RunWithContext: %w", err)
1162+
log.Error("error during GetDiff(git diff dir: %s): %v, stderr: %s", repoPath, err, stderr.String())
11631163
}
11641164

11651165
_ = writer.Close()

0 commit comments

Comments
 (0)