Skip to content

Commit a68baa0

Browse files
authored
Merge branch 'main' into star/list
2 parents 81cff53 + fa0c8ae commit a68baa0

File tree

26 files changed

+344
-327
lines changed

26 files changed

+344
-327
lines changed

main_timezones.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
//go:build windows
5+
6+
package main
7+
8+
// Golang has the ability to load OS's timezone data from most UNIX systems (https://github.com/golang/go/blob/master/src/time/zoneinfo_unix.go)
9+
// Even if the timezone data is missing, users could install the related packages to get it.
10+
// But on Windows, although `zoneinfo_windows.go` tries to load the timezone data from Windows registry,
11+
// some users still suffer from the issue that the timezone data is missing: https://github.com/go-gitea/gitea/issues/33235
12+
// So we import the tzdata package to make sure the timezone data is included in the binary.
13+
//
14+
// For non-Windows package builders, they could still use the "TAGS=timetzdata" to include the tzdata package in the binary.
15+
// If we decided to add the tzdata for other platforms, modify the "go:build" directive above.
16+
import _ "time/tzdata"

models/issues/issue_project.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ func (issue *Issue) projectID(ctx context.Context) int64 {
3838
}
3939

4040
// ProjectColumnID return project column id if issue was assigned to one
41-
func (issue *Issue) ProjectColumnID(ctx context.Context) int64 {
41+
func (issue *Issue) ProjectColumnID(ctx context.Context) (int64, error) {
4242
var ip project_model.ProjectIssue
4343
has, err := db.GetEngine(ctx).Where("issue_id=?", issue.ID).Get(&ip)
44-
if err != nil || !has {
45-
return 0
44+
if err != nil {
45+
return 0, err
46+
} else if !has {
47+
return 0, nil
4648
}
47-
return ip.ProjectColumnID
49+
return ip.ProjectColumnID, nil
4850
}
4951

5052
// LoadIssuesFromColumn load issues assigned to this column

modules/indexer/issues/util.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD
9292
projectID = issue.Project.ID
9393
}
9494

95+
projectColumnID, err := issue.ProjectColumnID(ctx)
96+
if err != nil {
97+
return nil, false, err
98+
}
99+
95100
return &internal.IndexerData{
96101
ID: issue.ID,
97102
RepoID: issue.RepoID,
@@ -106,7 +111,7 @@ func getIssueIndexerData(ctx context.Context, issueID int64) (*internal.IndexerD
106111
NoLabel: len(labels) == 0,
107112
MilestoneID: issue.MilestoneID,
108113
ProjectID: projectID,
109-
ProjectColumnID: issue.ProjectColumnID(ctx),
114+
ProjectColumnID: projectColumnID,
110115
PosterID: issue.PosterID,
111116
AssigneeID: issue.AssigneeID,
112117
MentionIDs: mentionIDs,

options/locale/locale_ga-IE.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,14 @@ view_as_role=Féach mar: %s
28772877
view_as_public_hint=Tá tú ag féachaint ar an README mar úsáideoir poiblí.
28782878
view_as_member_hint=Tá tú ag féachaint ar an README mar bhall den eagraíocht seo.
28792879

2880+
worktime=Am oibre
2881+
worktime.date_range_start=Dáta tosaithe
2882+
worktime.date_range_end=Dáta deiridh
2883+
worktime.query=Ceist
2884+
worktime.time=Am
2885+
worktime.by_repositories=De réir stórtha
2886+
worktime.by_milestones=De réir clocha míle
2887+
worktime.by_members=Ag baill
28802888

28812889
[admin]
28822890
maintenance=Cothabháil

options/locale/locale_pt-PT.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,6 +2877,14 @@ view_as_role=Ver como: %s
28772877
view_as_public_hint=Está a ver o README como um utilizador público.
28782878
view_as_member_hint=Está a ver o README como um membro desta organização.
28792879

2880+
worktime=Tempo de trabalho
2881+
worktime.date_range_start=Data do início
2882+
worktime.date_range_end=Data do fim
2883+
worktime.query=Consulta
2884+
worktime.time=Tempo
2885+
worktime.by_repositories=Por repositórios
2886+
worktime.by_milestones=Por etapas
2887+
worktime.by_members=Por membros
28802888

28812889
[admin]
28822890
maintenance=Manutenção

routers/web/org/home.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func Home(ctx *context.Context) {
3434
}
3535

3636
ctx.SetPathParam("org", uname)
37-
context.HandleOrgAssignment(ctx)
37+
context.OrgAssignment(context.OrgAssignmentOptions{})(ctx)
3838
if ctx.Written() {
3939
return
4040
}

routers/web/repo/repo.go

Lines changed: 0 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -304,31 +304,6 @@ func CreatePost(ctx *context.Context) {
304304
handleCreateError(ctx, ctxUser, err, "CreatePost", tplCreate, &form)
305305
}
306306

307-
const (
308-
tplWatchUnwatch templates.TplName = "repo/watch_unwatch"
309-
tplStarUnstar templates.TplName = "repo/star_unstar"
310-
)
311-
312-
func acceptTransfer(ctx *context.Context) {
313-
err := repo_service.AcceptTransferOwnership(ctx, ctx.Repo.Repository, ctx.Doer)
314-
if err == nil {
315-
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.success"))
316-
ctx.Redirect(ctx.Repo.Repository.Link())
317-
return
318-
}
319-
handleActionError(ctx, err)
320-
}
321-
322-
func rejectTransfer(ctx *context.Context) {
323-
err := repo_service.RejectRepositoryTransfer(ctx, ctx.Repo.Repository, ctx.Doer)
324-
if err == nil {
325-
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.rejected"))
326-
ctx.Redirect(ctx.Repo.Repository.Link())
327-
return
328-
}
329-
handleActionError(ctx, err)
330-
}
331-
332307
func handleActionError(ctx *context.Context, err error) {
333308
if errors.Is(err, user_model.ErrBlockedUser) {
334309
ctx.Flash.Error(ctx.Tr("repo.action.blocked_user"))
@@ -339,72 +314,6 @@ func handleActionError(ctx *context.Context, err error) {
339314
}
340315
}
341316

342-
// Action response for actions to a repository
343-
func Action(ctx *context.Context) {
344-
var err error
345-
switch ctx.PathParam("action") {
346-
case "watch":
347-
err = repo_model.WatchRepo(ctx, ctx.Doer, ctx.Repo.Repository, true)
348-
case "unwatch":
349-
err = repo_model.WatchRepo(ctx, ctx.Doer, ctx.Repo.Repository, false)
350-
case "star":
351-
err = repo_model.StarRepo(ctx, ctx.Doer, ctx.Repo.Repository, true)
352-
case "unstar":
353-
err = repo_model.StarRepo(ctx, ctx.Doer, ctx.Repo.Repository, false)
354-
case "accept_transfer":
355-
acceptTransfer(ctx)
356-
return
357-
case "reject_transfer":
358-
rejectTransfer(ctx)
359-
return
360-
case "desc": // FIXME: this is not used
361-
if !ctx.Repo.IsOwner() {
362-
ctx.Error(http.StatusNotFound)
363-
return
364-
}
365-
366-
ctx.Repo.Repository.Description = ctx.FormString("desc")
367-
ctx.Repo.Repository.Website = ctx.FormString("site")
368-
err = repo_service.UpdateRepository(ctx, ctx.Repo.Repository, false)
369-
}
370-
371-
if err != nil {
372-
handleActionError(ctx, err)
373-
return
374-
}
375-
376-
switch ctx.PathParam("action") {
377-
case "watch", "unwatch":
378-
ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
379-
case "star", "unstar":
380-
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
381-
}
382-
383-
// see the `hx-trigger="refreshUserCards ..."` comments in tmpl
384-
ctx.RespHeader().Add("hx-trigger", "refreshUserCards")
385-
386-
switch ctx.PathParam("action") {
387-
case "watch", "unwatch", "star", "unstar":
388-
// we have to reload the repository because NumStars or NumWatching (used in the templates) has just changed
389-
ctx.Data["Repository"], err = repo_model.GetRepositoryByName(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.Name)
390-
if err != nil {
391-
ctx.ServerError(fmt.Sprintf("Action (%s)", ctx.PathParam("action")), err)
392-
return
393-
}
394-
}
395-
396-
switch ctx.PathParam("action") {
397-
case "watch", "unwatch":
398-
ctx.HTML(http.StatusOK, tplWatchUnwatch)
399-
return
400-
case "star", "unstar":
401-
ctx.HTML(http.StatusOK, tplStarUnstar)
402-
return
403-
}
404-
405-
ctx.RedirectToCurrentSite(ctx.FormString("redirect_to"), ctx.Repo.RepoLink)
406-
}
407-
408317
// RedirectDownload return a file based on the following infos:
409318
func RedirectDownload(ctx *context.Context) {
410319
var (

routers/web/repo/star.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package repo
5+
6+
import (
7+
"net/http"
8+
9+
repo_model "code.gitea.io/gitea/models/repo"
10+
"code.gitea.io/gitea/modules/templates"
11+
"code.gitea.io/gitea/services/context"
12+
)
13+
14+
const tplStarUnstar templates.TplName = "repo/star_unstar"
15+
16+
func ActionStar(ctx *context.Context) {
17+
err := repo_model.StarRepo(ctx, ctx.Doer, ctx.Repo.Repository, ctx.PathParam("action") == "star")
18+
if err != nil {
19+
handleActionError(ctx, err)
20+
return
21+
}
22+
23+
ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
24+
ctx.Data["Repository"], err = repo_model.GetRepositoryByName(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.Name)
25+
if err != nil {
26+
ctx.ServerError("GetRepositoryByName", err)
27+
return
28+
}
29+
ctx.RespHeader().Add("hx-trigger", "refreshUserCards") // see the `hx-trigger="refreshUserCards ..."` comments in tmpl
30+
ctx.HTML(http.StatusOK, tplStarUnstar)
31+
}

routers/web/repo/transfer.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package repo
5+
6+
import (
7+
"code.gitea.io/gitea/services/context"
8+
repo_service "code.gitea.io/gitea/services/repository"
9+
)
10+
11+
func acceptTransfer(ctx *context.Context) {
12+
err := repo_service.AcceptTransferOwnership(ctx, ctx.Repo.Repository, ctx.Doer)
13+
if err == nil {
14+
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.success"))
15+
ctx.Redirect(ctx.Repo.Repository.Link())
16+
return
17+
}
18+
handleActionError(ctx, err)
19+
}
20+
21+
func rejectTransfer(ctx *context.Context) {
22+
err := repo_service.RejectRepositoryTransfer(ctx, ctx.Repo.Repository, ctx.Doer)
23+
if err == nil {
24+
ctx.Flash.Success(ctx.Tr("repo.settings.transfer.rejected"))
25+
ctx.Redirect(ctx.Repo.Repository.Link())
26+
return
27+
}
28+
handleActionError(ctx, err)
29+
}
30+
31+
func ActionTransfer(ctx *context.Context) {
32+
switch ctx.PathParam("action") {
33+
case "accept_transfer":
34+
acceptTransfer(ctx)
35+
case "reject_transfer":
36+
rejectTransfer(ctx)
37+
}
38+
}

routers/web/repo/watch.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package repo
5+
6+
import (
7+
"net/http"
8+
9+
repo_model "code.gitea.io/gitea/models/repo"
10+
"code.gitea.io/gitea/modules/templates"
11+
"code.gitea.io/gitea/services/context"
12+
)
13+
14+
const tplWatchUnwatch templates.TplName = "repo/watch_unwatch"
15+
16+
func ActionWatch(ctx *context.Context) {
17+
err := repo_model.WatchRepo(ctx, ctx.Doer, ctx.Repo.Repository, ctx.PathParam("action") == "watch")
18+
if err != nil {
19+
handleActionError(ctx, err)
20+
return
21+
}
22+
23+
ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx, ctx.Doer.ID, ctx.Repo.Repository.ID)
24+
ctx.Data["Repository"], err = repo_model.GetRepositoryByName(ctx, ctx.Repo.Repository.OwnerID, ctx.Repo.Repository.Name)
25+
if err != nil {
26+
ctx.ServerError("GetRepositoryByName", err)
27+
return
28+
}
29+
ctx.RespHeader().Add("hx-trigger", "refreshUserCards") // see the `hx-trigger="refreshUserCards ..."` comments in tmpl
30+
ctx.HTML(http.StatusOK, tplWatchUnwatch)
31+
}

routers/web/user/profile.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb
313313
ctx.Data["Page"] = pager
314314
}
315315

316-
// Action response for follow/unfollow user request
317-
func Action(ctx *context.Context) {
316+
// ActionUserFollow is for follow/unfollow user request
317+
func ActionUserFollow(ctx *context.Context) {
318318
var err error
319319
switch ctx.FormString("action") {
320320
case "follow":
@@ -339,6 +339,6 @@ func Action(ctx *context.Context) {
339339
ctx.HTML(http.StatusOK, tplFollowUnfollow)
340340
return
341341
}
342-
log.Error("Failed to apply action %q: unsupport context user type: %s", ctx.FormString("action"), ctx.ContextUser.Type)
342+
log.Error("Failed to apply action %q: unsupported context user type: %s", ctx.FormString("action"), ctx.ContextUser.Type)
343343
ctx.Error(http.StatusBadRequest, fmt.Sprintf("Action %q failed", ctx.FormString("action")))
344344
}

0 commit comments

Comments
 (0)