Skip to content

Commit 2609e92

Browse files
authored
Merge branch 'main' into fix_33321
2 parents b34ab60 + 7e596bd commit 2609e92

File tree

4 files changed

+47
-17
lines changed

4 files changed

+47
-17
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,

services/projects/issue.go

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,29 @@ func MoveIssuesOnProjectColumn(ctx context.Context, doer *user_model.User, colum
5555
continue
5656
}
5757

58-
_, err = db.Exec(ctx, "UPDATE `project_issue` SET project_board_id=?, sorting=? WHERE issue_id=?", column.ID, sorting, issueID)
58+
projectColumnID, err := curIssue.ProjectColumnID(ctx)
5959
if err != nil {
6060
return err
6161
}
6262

63-
// add timeline to issue
64-
if _, err := issues_model.CreateComment(ctx, &issues_model.CreateCommentOptions{
65-
Type: issues_model.CommentTypeProjectColumn,
66-
Doer: doer,
67-
Repo: curIssue.Repo,
68-
Issue: curIssue,
69-
ProjectID: column.ProjectID,
70-
ProjectTitle: project.Title,
71-
ProjectColumnID: column.ID,
72-
ProjectColumnTitle: column.Title,
73-
}); err != nil {
63+
if projectColumnID != column.ID {
64+
// add timeline to issue
65+
if _, err := issues_model.CreateComment(ctx, &issues_model.CreateCommentOptions{
66+
Type: issues_model.CommentTypeProjectColumn,
67+
Doer: doer,
68+
Repo: curIssue.Repo,
69+
Issue: curIssue,
70+
ProjectID: column.ProjectID,
71+
ProjectTitle: project.Title,
72+
ProjectColumnID: column.ID,
73+
ProjectColumnTitle: column.Title,
74+
}); err != nil {
75+
return err
76+
}
77+
}
78+
79+
_, err = db.Exec(ctx, "UPDATE `project_issue` SET project_board_id=?, sorting=? WHERE issue_id=?", column.ID, sorting, issueID)
80+
if err != nil {
7481
return err
7582
}
7683
}

0 commit comments

Comments
 (0)