Skip to content

Commit ac69eb3

Browse files
committed
Merge branch 'cast' of github.com:silverwind/gitea into cast
* 'cast' of github.com:silverwind/gitea: Fix Mermaid diagrams failing when node labels contain line breaks (go-gitea#37296) Add project column picker to issue and pull request sidebar (go-gitea#37037) Fix container auth for public instance (go-gitea#37290) Refactor frontend `tw-justify-between` layouts to `flex-left-right` (go-gitea#37291) Update Nix flake (go-gitea#37284) Workflow Artifact Info Hover (go-gitea#37100)
2 parents bbdde52 + e03f3f0 commit ac69eb3

69 files changed

Lines changed: 605 additions & 169 deletions

Some content is hidden

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

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
- Never force-push, amend, or squash unless asked. Use new commits and normal push for pull request updates
88
- Preserve existing code comments, do not remove or rewrite comments that are still relevant
99
- In TypeScript, use `!` (non-null assertion) instead of `?.`/`??` when a value is known to always exist
10+
- For CSS layout, prefer `flex-*` helpers over per-child `tw-ml-*` / `tw-mr-*` margins; fall back to `tw-*` utilities when specificity requires `!important`
1011
- Include authorship attribution in issue and pull request comments
1112
- Add `Co-Authored-By` lines to all commits, indicating name and model used

flake.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

models/actions/artifact.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ type ActionArtifactMeta struct {
183183
ArtifactName string
184184
FileSize int64
185185
Status ArtifactStatus
186+
ExpiredUnix timeutil.TimeStamp
186187
}
187188

188189
// ListUploadedArtifactsMeta returns all uploaded artifacts meta of a run
@@ -191,7 +192,7 @@ func ListUploadedArtifactsMeta(ctx context.Context, repoID, runID int64) ([]*Act
191192
return arts, db.GetEngine(ctx).Table("action_artifact").
192193
Where("repo_id=? AND run_id=? AND (status=? OR status=?)", repoID, runID, ArtifactStatusUploadConfirmed, ArtifactStatusExpired).
193194
GroupBy("artifact_name").
194-
Select("artifact_name, sum(file_size) as file_size, max(status) as status").
195+
Select("artifact_name, sum(file_size) as file_size, max(status) as status, max(expired_unix) as expired_unix").
195196
Find(&arts)
196197
}
197198

models/issues/issue.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,17 @@ func GetIssueByID(ctx context.Context, id int64) (*Issue, error) {
592592
return issue, nil
593593
}
594594

595+
func GetIssueByRepoID(ctx context.Context, repoID, issueID int64) (*Issue, error) {
596+
issue := new(Issue)
597+
has, err := db.GetEngine(ctx).ID(issueID).Where("repo_id=?", repoID).Get(issue)
598+
if err != nil {
599+
return nil, err
600+
} else if !has {
601+
return nil, ErrIssueNotExist{issueID, repoID, 0}
602+
}
603+
return issue, nil
604+
}
605+
595606
// GetIssuesByIDs return issues with the given IDs.
596607
// If keepOrder is true, the order of the returned issues will be the same as the given IDs.
597608
func GetIssuesByIDs(ctx context.Context, issueIDs []int64, keepOrder ...bool) (IssueList, error) {

models/issues/issue_project.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,10 @@ func IssueAssignOrRemoveProject(ctx context.Context, issue *Issue, doer *user_mo
115115
panic("newColumnID must not be zero") // shouldn't happen
116116
}
117117

118-
res := struct {
119-
MaxSorting int64
120-
IssueCount int64
121-
}{}
122-
if _, err := db.GetEngine(ctx).Select("max(sorting) as max_sorting, count(*) as issue_count").Table("project_issue").
123-
Where("project_id=?", newProjectID).
124-
And("project_board_id=?", newColumnID).
125-
Get(&res); err != nil {
118+
newSorting, err := project_model.GetColumnIssueNextSorting(ctx, newProjectID, newColumnID)
119+
if err != nil {
126120
return err
127121
}
128-
newSorting := util.Iif(res.IssueCount > 0, res.MaxSorting+1, 0)
129122
return db.Insert(ctx, &project_model.ProjectIssue{
130123
IssueID: issue.ID,
131124
ProjectID: newProjectID,

models/project/column.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func deleteColumnByID(ctx context.Context, columnID int64) error {
185185
return err
186186
}
187187

188-
if err = column.moveIssuesToAnotherColumn(ctx, defaultColumn); err != nil {
188+
if err = moveIssuesToAnotherColumn(ctx, column, defaultColumn); err != nil {
189189
return err
190190
}
191191

models/project/column_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func Test_moveIssuesToAnotherColumn(t *testing.T) {
5959
assert.Len(t, issues, 1)
6060
assert.EqualValues(t, 3, issues[0].ID)
6161

62-
err = column1.moveIssuesToAnotherColumn(t.Context(), column2)
62+
err = moveIssuesToAnotherColumn(t.Context(), column1, column2)
6363
assert.NoError(t, err)
6464

6565
issues, err = column1.GetIssues(t.Context())

models/project/issue.go

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,45 @@ func deleteProjectIssuesByProjectID(ctx context.Context, projectID int64) error
3333
return err
3434
}
3535

36-
func (c *Column) moveIssuesToAnotherColumn(ctx context.Context, newColumn *Column) error {
37-
if c.ProjectID != newColumn.ProjectID {
38-
return errors.New("columns have to be in the same project")
39-
}
40-
41-
if c.ID == newColumn.ID {
42-
return nil
43-
}
44-
36+
// GetColumnIssueNextSorting returns the sorting value to append an issue at the end of the column.
37+
func GetColumnIssueNextSorting(ctx context.Context, projectID, columnID int64) (int64, error) {
4538
res := struct {
4639
MaxSorting int64
4740
IssueCount int64
4841
}{}
49-
if _, err := db.GetEngine(ctx).Select("max(sorting) as max_sorting, count(*) as issue_count").
42+
if _, err := db.GetEngine(ctx).Select("max(sorting) AS max_sorting, count(*) AS issue_count").
5043
Table("project_issue").
51-
Where("project_id=?", newColumn.ProjectID).
52-
And("project_board_id=?", newColumn.ID).
44+
Where("project_id=?", projectID).
45+
And("project_board_id=?", columnID).
5346
Get(&res); err != nil {
54-
return err
47+
return 0, err
5548
}
49+
return util.Iif(res.IssueCount > 0, res.MaxSorting+1, 0), nil
50+
}
5651

57-
issues, err := c.GetIssues(ctx)
52+
func moveIssuesToAnotherColumn(ctx context.Context, oldColumn, newColumn *Column) error {
53+
if oldColumn.ProjectID != newColumn.ProjectID {
54+
return errors.New("columns have to be in the same project")
55+
}
56+
57+
if oldColumn.ID == newColumn.ID {
58+
return nil
59+
}
60+
61+
movedIssues, err := oldColumn.GetIssues(ctx)
5862
if err != nil {
5963
return err
6064
}
61-
if len(issues) == 0 {
65+
if len(movedIssues) == 0 {
6266
return nil
6367
}
6468

65-
nextSorting := util.Iif(res.IssueCount > 0, res.MaxSorting+1, 0)
69+
nextSorting, err := GetColumnIssueNextSorting(ctx, newColumn.ProjectID, newColumn.ID)
70+
if err != nil {
71+
return err
72+
}
6673
return db.WithTx(ctx, func(ctx context.Context) error {
67-
for i, issue := range issues {
74+
for i, issue := range movedIssues {
6875
issue.ProjectColumnID = newColumn.ID
6976
issue.Sorting = nextSorting + int64(i)
7077
if _, err := db.GetEngine(ctx).ID(issue.ID).Cols("project_board_id", "sorting").Update(issue); err != nil {

options/locale/locale_en-US.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"unpin": "Unpin",
123123
"artifacts": "Artifacts",
124124
"expired": "Expired",
125+
"artifact_expires_at": "Expires at %s",
125126
"confirm_delete_artifact": "Are you sure you want to delete the artifact '%s'?",
126127
"archived": "Archived",
127128
"concept_system_global": "Global",
@@ -1406,11 +1407,12 @@
14061407
"repo.issues.new": "New Issue",
14071408
"repo.issues.new.title_empty": "Title cannot be empty",
14081409
"repo.issues.new.labels": "Labels",
1409-
"repo.issues.new.no_label": "No Label",
1410+
"repo.issues.new.no_labels": "No labels",
14101411
"repo.issues.new.clear_labels": "Clear labels",
14111412
"repo.issues.new.projects": "Projects",
14121413
"repo.issues.new.clear_projects": "Clear projects",
1413-
"repo.issues.new.no_projects": "No project",
1414+
"repo.issues.new.no_projects": "No projects",
1415+
"repo.issues.new.no_column": "No column",
14141416
"repo.issues.new.open_projects": "Open Projects",
14151417
"repo.issues.new.closed_projects": "Closed Projects",
14161418
"repo.issues.new.no_items": "No items",

routers/api/packages/container/container.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
container_module "code.gitea.io/gitea/modules/packages/container"
2828
"code.gitea.io/gitea/modules/setting"
2929
"code.gitea.io/gitea/modules/storage"
30+
"code.gitea.io/gitea/modules/structs"
3031
"code.gitea.io/gitea/modules/util"
3132
"code.gitea.io/gitea/routers/api/packages/helper"
3233
auth_service "code.gitea.io/gitea/services/auth"
@@ -125,8 +126,15 @@ func APIUnauthorizedError(ctx *context.Context) {
125126
// container registry requires that the "/v2" must be in the root, so the sub-path in AppURL should be removed
126127
realmURL := httplib.GuessCurrentHostURL(ctx) + "/v2/token"
127128
ctx.Resp.Header().Add("WWW-Authenticate", `Bearer realm="`+realmURL+`",service="container_registry",scope="*"`)
128-
// support apple container like: container registry login <gitea-host> -u
129-
ctx.Resp.Header().Add("WWW-Authenticate", `Basic realm="Gitea Container Registry"`)
129+
130+
ownerName := ctx.PathParam("username")
131+
owner, _ := user_model.GetUserByName(ctx, ownerName)
132+
requireSignIn := owner != nil && owner.Visibility != structs.VisibleTypePublic
133+
requireSignIn = requireSignIn || setting.Service.RequireSignInViewStrict
134+
if requireSignIn {
135+
// support apple container like: container registry login <gitea-host> -u
136+
ctx.Resp.Header().Add("WWW-Authenticate", `Basic realm="Gitea Container Registry"`)
137+
}
130138
apiErrorDefined(ctx, errUnauthorized)
131139
}
132140

0 commit comments

Comments
 (0)