Skip to content

Commit 588c6b1

Browse files
committed
fix
1 parent ed8d4dc commit 588c6b1

File tree

47 files changed

+99
-101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+99
-101
lines changed

cmd/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func runRepoSyncReleases(ctx context.Context, _ *cli.Command) error {
100100
return err
101101
}
102102

103-
if err := git.InitSimple(ctx); err != nil {
103+
if err := git.InitSimple(); err != nil {
104104
return err
105105
}
106106

cmd/dump_repo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func runDumpRepository(ctx context.Context, cmd *cli.Command) error {
9090
}
9191

9292
// migrations.GiteaLocalUploader depends on git module
93-
if err := git.InitSimple(context.Background()); err != nil {
93+
if err := git.InitSimple(); err != nil {
9494
return err
9595
}
9696

@@ -179,7 +179,7 @@ func runDumpRepository(ctx context.Context, cmd *cli.Command) error {
179179
}
180180

181181
if err := migrations.DumpRepository(
182-
context.Background(),
182+
ctx,
183183
repoDir,
184184
cmd.String("owner_name"),
185185
opts,

cmd/serv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func setup(ctx context.Context, debug bool) {
6565
_ = fail(ctx, "Unable to access repository path", "Unable to access repository path %q, err: %v", setting.RepoRootPath, err)
6666
return
6767
}
68-
if err := git.InitSimple(context.Background()); err != nil {
68+
if err := git.InitSimple(); err != nil {
6969
_ = fail(ctx, "Failed to init git", "Failed to init git, err: %v", err)
7070
}
7171
}

cmd/web.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,16 @@ func serveInstalled(c *cli.Command) error {
236236
}
237237

238238
func servePprof() {
239+
// FIXME: it shouldn't use the global DefaultServeMux, and it should use a proper context
239240
http.DefaultServeMux.Handle("/debug/fgprof", fgprof.Handler())
240-
_, _, finished := process.GetManager().AddTypedContext(context.Background(), "Web: PProf Server", process.SystemProcessType, true)
241-
// The pprof server is for debug purpose only, it shouldn't be exposed on public network. At the moment it's not worth to introduce a configurable option for it.
241+
_, _, finished := process.GetManager().AddTypedContext(context.TODO(), "Web: PProf Server", process.SystemProcessType, true)
242+
// The pprof server is for debug purpose only, it shouldn't be exposed on public network. At the moment, it's not worth introducing a configurable option for it.
242243
log.Info("Starting pprof server on localhost:6060")
243244
log.Info("Stopped pprof server: %v", http.ListenAndServe("localhost:6060", nil))
244245
finished()
245246
}
246247

247-
func runWeb(_ context.Context, cmd *cli.Command) error {
248+
func runWeb(ctx context.Context, cmd *cli.Command) error {
248249
defer func() {
249250
if panicked := recover(); panicked != nil {
250251
log.Fatal("PANIC: %v\n%s", panicked, log.Stack(2))
@@ -255,7 +256,7 @@ func runWeb(_ context.Context, cmd *cli.Command) error {
255256
return fmt.Errorf("unknown command: %s", subCmdName)
256257
}
257258

258-
managerCtx, cancel := context.WithCancel(context.Background())
259+
managerCtx, cancel := context.WithCancel(ctx)
259260
graceful.InitManager(managerCtx)
260261
defer cancel()
261262

models/activities/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func (a *Action) GetCommentHTMLURL(ctx context.Context) string {
320320
return "#"
321321
}
322322

323-
return a.Issue.HTMLURL()
323+
return a.Issue.HTMLURL(ctx)
324324
}
325325

326326
// GetCommentLink returns link to action comment.

models/activities/notification.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,11 @@ func (n *Notification) HTMLURL(ctx context.Context) string {
280280
if n.Comment != nil {
281281
return n.Comment.HTMLURL(ctx)
282282
}
283-
return n.Issue.HTMLURL()
283+
return n.Issue.HTMLURL(ctx)
284284
case NotificationSourceCommit:
285-
return n.Repository.HTMLURL() + "/commit/" + url.PathEscape(n.CommitID)
285+
return n.Repository.HTMLURL(ctx) + "/commit/" + url.PathEscape(n.CommitID)
286286
case NotificationSourceRepository:
287-
return n.Repository.HTMLURL()
287+
return n.Repository.HTMLURL(ctx)
288288
}
289289
return ""
290290
}

models/issues/comment.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ func (c *Comment) HTMLURL(ctx context.Context) string {
414414
log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
415415
return ""
416416
}
417-
return c.Issue.HTMLURL() + c.hashLink(ctx)
417+
return c.Issue.HTMLURL(ctx) + c.hashLink(ctx)
418418
}
419419

420420
// Link formats a relative URL-string to the issue-comment
@@ -483,7 +483,7 @@ func (c *Comment) IssueURL(ctx context.Context) string {
483483
log.Error("loadRepo(%d): %v", c.Issue.RepoID, err)
484484
return ""
485485
}
486-
return c.Issue.HTMLURL()
486+
return c.Issue.HTMLURL(ctx)
487487
}
488488

489489
// PRURL formats a URL-string to the pull-request
@@ -503,7 +503,7 @@ func (c *Comment) PRURL(ctx context.Context) string {
503503
if !c.Issue.IsPull {
504504
return ""
505505
}
506-
return c.Issue.HTMLURL()
506+
return c.Issue.HTMLURL(ctx)
507507
}
508508

509509
// CommentHashTag returns unique hash tag for comment id.

models/issues/issue.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,14 +405,14 @@ func (issue *Issue) APIURL(ctx context.Context) string {
405405
}
406406

407407
// HTMLURL returns the absolute URL to this issue.
408-
func (issue *Issue) HTMLURL() string {
408+
func (issue *Issue) HTMLURL(ctx context.Context) string {
409409
var path string
410410
if issue.IsPull {
411411
path = "pulls"
412412
} else {
413413
path = "issues"
414414
}
415-
return fmt.Sprintf("%s/%s/%d", issue.Repo.HTMLURL(), path, issue.Index)
415+
return fmt.Sprintf("%s/%s/%d", issue.Repo.HTMLURL(ctx), path, issue.Index)
416416
}
417417

418418
// Link returns the issue's relative URL.

models/migrations/base/tests.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package base
55

66
import (
7-
"context"
87
"fmt"
98
"os"
109
"path/filepath"
@@ -124,7 +123,7 @@ func MainTest(m *testing.M) {
124123
setting.AppDataPath = tmpDataPath
125124

126125
unittest.InitSettingsForTesting()
127-
if err = git.InitFull(context.Background()); err != nil {
126+
if err = git.InitFull(); err != nil {
128127
testlogger.Fatalf("Unable to InitFull: %v\n", err)
129128
}
130129
setting.LoadDBSetting()

models/migrations/migrations.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ func migrationIDNumberToDBVersion(idNumber int64) int64 {
456456
}
457457

458458
// Migrate database to current version
459-
func Migrate(x *xorm.Engine) error {
459+
func Migrate(ctx context.Context, x *xorm.Engine) error {
460460
migrations := prepareMigrationTasks()
461461
maxDBVer := calcDBVersion(migrations)
462462

@@ -501,7 +501,7 @@ Please try upgrading to a lower version first (suggested v1.6.4), then upgrade t
501501

502502
// Some migration tasks depend on the git command
503503
if git.DefaultContext == nil {
504-
if err = git.InitSimple(context.Background()); err != nil {
504+
if err = git.InitSimple(); err != nil {
505505
return err
506506
}
507507
}

0 commit comments

Comments
 (0)