Skip to content

Commit f691fbe

Browse files
committed
Merge remote-tracking branch 'upstream/main'
* upstream/main: Fix users cannot visit issue attachment bug (go-gitea#25019) Fix incorrect issuel filter menu style (go-gitea#25018) Update repo's default branch when adding new files in an empty one (go-gitea#25017) Rename NotifyPullReviewRequest to NotifyPullRequestReviewRequest (go-gitea#24988) Merge `new project` templates into one (go-gitea#24985) Add chinese documentations for `cran package registry` (go-gitea#25012)
2 parents a30724d + 5d23c88 commit f691fbe

File tree

23 files changed

+222
-302
lines changed

23 files changed

+222
-302
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ cpu.out
4747

4848
*.db
4949
*.log
50+
*.log.*.gz
5051

5152
/gitea
5253
/gitea-vet
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
date: "2023-01-01T00:00:00+00:00"
3+
title: "CRAN 软件包注册表"
4+
slug: "cran"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "packages"
10+
name: "CRAN"
11+
weight: 35
12+
identifier: "cran"
13+
---
14+
15+
# CRAN 软件包注册表
16+
17+
[R](https://www.r-project.org/) 软件包发布到您的用户或组织的类似 [CRAN](https://cran.r-project.org/) 的注册表。
18+
19+
**目录**
20+
21+
{{< toc >}}
22+
23+
## 要求
24+
25+
要使用CRAN软件包注册表,您需要安装 [R](https://cran.r-project.org/)
26+
27+
## 配置软件包注册表
28+
29+
要注册软件包注册表,您需要将其添加到 `Rprofile.site` 文件中,可以是系统级别、用户级别 `~/.Rprofile` 或项目级别:
30+
31+
```
32+
options("repos" = c(getOption("repos"), c(gitea="https://gitea.example.com/api/packages/{owner}/cran")))
33+
```
34+
35+
| 参数 | 描述 |
36+
| ------- | -------------- |
37+
| `owner` | 软件包的所有者 |
38+
39+
如果需要提供凭据,可以将它们嵌入到URL(`https://user:[email protected]/...`)中。
40+
41+
## 发布软件包
42+
43+
要发布 R 软件包,请执行带有软件包内容的 HTTP `PUT` 操作。
44+
45+
源代码软件包:
46+
47+
```
48+
PUT https://gitea.example.com/api/packages/{owner}/cran/src
49+
```
50+
51+
| 参数 | 描述 |
52+
| ------- | -------------- |
53+
| `owner` | 软件包的所有者 |
54+
55+
二进制软件包:
56+
57+
```
58+
PUT https://gitea.example.com/api/packages/{owner}/cran/bin?platform={platform}&rversion={rversion}
59+
```
60+
61+
| 参数 | 描述 |
62+
| ---------- | -------------- |
63+
| `owner` | 软件包的所有者 |
64+
| `platform` | 平台的名称 |
65+
| `rversion` | 二进制的R版本 |
66+
67+
例如:
68+
69+
```shell
70+
curl --user your_username:your_password_or_token \
71+
--upload-file path/to/package.zip \
72+
https://gitea.example.com/api/packages/testuser/cran/bin?platform=windows&rversion=4.2
73+
```
74+
75+
如果同名和版本的软件包已存在,则无法发布软件包。您必须首先删除现有的软件包。
76+
77+
## 安装软件包
78+
79+
要从软件包注册表中安装R软件包,请执行以下命令:
80+
81+
```shell
82+
install.packages("{package_name}")
83+
```
84+
85+
| 参数 | 描述 |
86+
| -------------- | ----------------- |
87+
| `package_name` | The package name. |
88+
89+
例如:
90+
91+
```shell
92+
install.packages("testpackage")
93+
```

modules/notification/base/notifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type Notifier interface {
2828
NotifyDeleteIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue)
2929
NotifyIssueChangeMilestone(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldMilestoneID int64)
3030
NotifyIssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment)
31-
NotifyPullReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment)
31+
NotifyPullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment)
3232
NotifyIssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string)
3333
NotifyIssueClearLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue)
3434
NotifyIssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string)

modules/notification/base/null.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ func (*NullNotifier) NotifyIssueChangeContent(ctx context.Context, doer *user_mo
120120
func (*NullNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment) {
121121
}
122122

123-
// NotifyPullReviewRequest places a place holder function
124-
func (*NullNotifier) NotifyPullReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
123+
// NotifyPullRequestReviewRequest places a place holder function
124+
func (*NullNotifier) NotifyPullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
125125
}
126126

127127
// NotifyIssueClearLabels places a place holder function

modules/notification/mail/mail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (m *mailNotifier) NotifyIssueChangeAssignee(ctx context.Context, doer *user
123123
}
124124
}
125125

126-
func (m *mailNotifier) NotifyPullReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
126+
func (m *mailNotifier) NotifyPullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
127127
if isRequest && doer.ID != reviewer.ID && reviewer.EmailNotifications() != user_model.EmailNotificationsDisabled {
128128
ct := fmt.Sprintf("Requested to review %s.", issue.HTMLURL())
129129
if err := mailer.SendIssueAssignedMail(ctx, issue, doer, ct, comment, []*user_model.User{reviewer}); err != nil {

modules/notification/notification.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ func NotifyIssueChangeAssignee(ctx context.Context, doer *user_model.User, issue
230230
}
231231
}
232232

233-
// NotifyPullReviewRequest notifies Request Review change
234-
func NotifyPullReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
233+
// NotifyPullRequestReviewRequest notifies Request Review change
234+
func NotifyPullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
235235
for _, notifier := range notifiers {
236-
notifier.NotifyPullReviewRequest(ctx, doer, issue, reviewer, isRequest, comment)
236+
notifier.NotifyPullRequestReviewRequest(ctx, doer, issue, reviewer, isRequest, comment)
237237
}
238238
}
239239

modules/notification/ui/ui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func (ns *notificationService) NotifyIssueChangeAssignee(ctx context.Context, do
229229
}
230230
}
231231

232-
func (ns *notificationService) NotifyPullReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
232+
func (ns *notificationService) NotifyPullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
233233
if isRequest {
234234
opts := issueNotificationOpts{
235235
IssueID: issue.ID,

routers/web/org/projects.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ import (
2626
)
2727

2828
const (
29-
tplProjects base.TplName = "org/projects/list"
30-
tplProjectsNew base.TplName = "org/projects/new"
31-
tplProjectsView base.TplName = "org/projects/view"
32-
tplGenericProjectsNew base.TplName = "user/project"
29+
tplProjects base.TplName = "org/projects/list"
30+
tplProjectsNew base.TplName = "org/projects/new"
31+
tplProjectsView base.TplName = "org/projects/view"
3332
)
3433

3534
// MustEnableProjects check if projects are enabled in settings
@@ -125,14 +124,15 @@ func canWriteProjects(ctx *context.Context) bool {
125124
return ctx.Doer != nil && ctx.ContextUser.ID == ctx.Doer.ID
126125
}
127126

128-
// NewProject render creating a project page
129-
func NewProject(ctx *context.Context) {
127+
// RenderNewProject render creating a project page
128+
func RenderNewProject(ctx *context.Context) {
130129
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
131130
ctx.Data["BoardTypes"] = project_model.GetBoardConfig()
132131
ctx.Data["CardTypes"] = project_model.GetCardConfig()
133132
ctx.Data["CanWriteProjects"] = canWriteProjects(ctx)
134133
ctx.Data["PageIsViewProjects"] = true
135134
ctx.Data["HomeLink"] = ctx.ContextUser.HomeLink()
135+
ctx.Data["CancelLink"] = ctx.ContextUser.HomeLink() + "/-/projects"
136136
shared_user.RenderUserHeader(ctx)
137137
ctx.HTML(http.StatusOK, tplProjectsNew)
138138
}
@@ -144,11 +144,7 @@ func NewProjectPost(ctx *context.Context) {
144144
shared_user.RenderUserHeader(ctx)
145145

146146
if ctx.HasError() {
147-
ctx.Data["CanWriteProjects"] = canWriteProjects(ctx)
148-
ctx.Data["PageIsViewProjects"] = true
149-
ctx.Data["BoardTypes"] = project_model.GetBoardConfig()
150-
ctx.Data["CardTypes"] = project_model.GetCardConfig()
151-
ctx.HTML(http.StatusOK, tplProjectsNew)
147+
RenderNewProject(ctx)
152148
return
153149
}
154150

@@ -227,8 +223,8 @@ func DeleteProject(ctx *context.Context) {
227223
})
228224
}
229225

230-
// EditProject allows a project to be edited
231-
func EditProject(ctx *context.Context) {
226+
// RenderEditProject allows a project to be edited
227+
func RenderEditProject(ctx *context.Context) {
232228
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
233229
ctx.Data["PageIsEditProjects"] = true
234230
ctx.Data["PageIsViewProjects"] = true
@@ -257,18 +253,21 @@ func EditProject(ctx *context.Context) {
257253
ctx.Data["redirect"] = ctx.FormString("redirect")
258254
ctx.Data["HomeLink"] = ctx.ContextUser.HomeLink()
259255
ctx.Data["card_type"] = p.CardType
256+
ctx.Data["CancelLink"] = fmt.Sprintf("%s/-/projects/%d", ctx.ContextUser.HomeLink(), p.ID)
260257

261258
ctx.HTML(http.StatusOK, tplProjectsNew)
262259
}
263260

264261
// EditProjectPost response for editing a project
265262
func EditProjectPost(ctx *context.Context) {
266263
form := web.GetForm(ctx).(*forms.CreateProjectForm)
264+
projectID := ctx.ParamsInt64(":id")
267265
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
268266
ctx.Data["PageIsEditProjects"] = true
269267
ctx.Data["PageIsViewProjects"] = true
270268
ctx.Data["CanWriteProjects"] = canWriteProjects(ctx)
271269
ctx.Data["CardTypes"] = project_model.GetCardConfig()
270+
ctx.Data["CancelLink"] = fmt.Sprintf("%s/-/projects/%d", ctx.ContextUser.HomeLink(), projectID)
272271

273272
shared_user.RenderUserHeader(ctx)
274273

@@ -277,7 +276,7 @@ func EditProjectPost(ctx *context.Context) {
277276
return
278277
}
279278

280-
p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
279+
p, err := project_model.GetProjectByID(ctx, projectID)
281280
if err != nil {
282281
if project_model.IsErrProjectNotExist(err) {
283282
ctx.NotFound("", nil)

routers/web/repo/attachment.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,6 @@ func ServeAttachment(ctx *context.Context, uuid string) {
110110
return
111111
}
112112
} else { // If we have the repository we check access
113-
context.CheckRepoScopedToken(ctx, repository)
114-
if ctx.Written() {
115-
return
116-
}
117-
118113
perm, err := access_model.GetUserRepoPermission(ctx, repository, ctx.Doer)
119114
if err != nil {
120115
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err.Error())

routers/web/repo/projects.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@ import (
2727
)
2828

2929
const (
30-
tplProjects base.TplName = "repo/projects/list"
31-
tplProjectsNew base.TplName = "repo/projects/new"
32-
tplProjectsView base.TplName = "repo/projects/view"
33-
tplGenericProjectsNew base.TplName = "user/project"
30+
tplProjects base.TplName = "repo/projects/list"
31+
tplProjectsNew base.TplName = "repo/projects/new"
32+
tplProjectsView base.TplName = "repo/projects/view"
3433
)
3534

3635
// MustEnableProjects check if projects are enabled in settings
@@ -121,12 +120,13 @@ func Projects(ctx *context.Context) {
121120
ctx.HTML(http.StatusOK, tplProjects)
122121
}
123122

124-
// NewProject render creating a project page
125-
func NewProject(ctx *context.Context) {
123+
// RenderNewProject render creating a project page
124+
func RenderNewProject(ctx *context.Context) {
126125
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
127126
ctx.Data["BoardTypes"] = project_model.GetBoardConfig()
128127
ctx.Data["CardTypes"] = project_model.GetCardConfig()
129128
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
129+
ctx.Data["CancelLink"] = ctx.Repo.Repository.Link() + "/projects"
130130
ctx.HTML(http.StatusOK, tplProjectsNew)
131131
}
132132

@@ -136,10 +136,7 @@ func NewProjectPost(ctx *context.Context) {
136136
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
137137

138138
if ctx.HasError() {
139-
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
140-
ctx.Data["BoardTypes"] = project_model.GetBoardConfig()
141-
ctx.Data["CardTypes"] = project_model.GetCardConfig()
142-
ctx.HTML(http.StatusOK, tplProjectsNew)
139+
RenderNewProject(ctx)
143140
return
144141
}
145142

@@ -211,8 +208,8 @@ func DeleteProject(ctx *context.Context) {
211208
})
212209
}
213210

214-
// EditProject allows a project to be edited
215-
func EditProject(ctx *context.Context) {
211+
// RenderEditProject allows a project to be edited
212+
func RenderEditProject(ctx *context.Context) {
216213
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
217214
ctx.Data["PageIsEditProjects"] = true
218215
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
@@ -237,24 +234,28 @@ func EditProject(ctx *context.Context) {
237234
ctx.Data["content"] = p.Description
238235
ctx.Data["card_type"] = p.CardType
239236
ctx.Data["redirect"] = ctx.FormString("redirect")
237+
ctx.Data["CancelLink"] = fmt.Sprintf("%s/projects/%d", ctx.Repo.Repository.Link(), p.ID)
240238

241239
ctx.HTML(http.StatusOK, tplProjectsNew)
242240
}
243241

244242
// EditProjectPost response for editing a project
245243
func EditProjectPost(ctx *context.Context) {
246244
form := web.GetForm(ctx).(*forms.CreateProjectForm)
245+
projectID := ctx.ParamsInt64(":id")
246+
247247
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
248248
ctx.Data["PageIsEditProjects"] = true
249249
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
250250
ctx.Data["CardTypes"] = project_model.GetCardConfig()
251+
ctx.Data["CancelLink"] = fmt.Sprintf("%s/projects/%d", ctx.Repo.Repository.Link(), projectID)
251252

252253
if ctx.HasError() {
253254
ctx.HTML(http.StatusOK, tplProjectsNew)
254255
return
255256
}
256257

257-
p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
258+
p, err := project_model.GetProjectByID(ctx, projectID)
258259
if err != nil {
259260
if project_model.IsErrProjectNotExist(err) {
260261
ctx.NotFound("", nil)

routers/web/web.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -824,13 +824,13 @@ func registerRoutes(m *web.Route) {
824824
m.Get("/{id}", org.ViewProject)
825825
}, reqUnitAccess(unit.TypeProjects, perm.AccessModeRead))
826826
m.Group("", func() { //nolint:dupl
827-
m.Get("/new", org.NewProject)
827+
m.Get("/new", org.RenderNewProject)
828828
m.Post("/new", web.Bind(forms.CreateProjectForm{}), org.NewProjectPost)
829829
m.Group("/{id}", func() {
830830
m.Post("", web.Bind(forms.EditProjectBoardForm{}), org.AddBoardToProjectPost)
831831
m.Post("/delete", org.DeleteProject)
832832

833-
m.Get("/edit", org.EditProject)
833+
m.Get("/edit", org.RenderEditProject)
834834
m.Post("/edit", web.Bind(forms.CreateProjectForm{}), org.EditProjectPost)
835835
m.Post("/{action:open|close}", org.ChangeProjectStatus)
836836

@@ -1159,13 +1159,13 @@ func registerRoutes(m *web.Route) {
11591159
m.Get("", repo.Projects)
11601160
m.Get("/{id}", repo.ViewProject)
11611161
m.Group("", func() { //nolint:dupl
1162-
m.Get("/new", repo.NewProject)
1162+
m.Get("/new", repo.RenderNewProject)
11631163
m.Post("/new", web.Bind(forms.CreateProjectForm{}), repo.NewProjectPost)
11641164
m.Group("/{id}", func() {
11651165
m.Post("", web.Bind(forms.EditProjectBoardForm{}), repo.AddBoardToProjectPost)
11661166
m.Post("/delete", repo.DeleteProject)
11671167

1168-
m.Get("/edit", repo.EditProject)
1168+
m.Get("/edit", repo.RenderEditProject)
11691169
m.Post("/edit", web.Bind(forms.CreateProjectForm{}), repo.EditProjectPost)
11701170
m.Post("/{action:open|close}", repo.ChangeProjectStatus)
11711171

services/issue/assignee.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func ReviewRequest(ctx context.Context, issue *issues_model.Issue, doer, reviewe
7373
}
7474

7575
if comment != nil {
76-
notification.NotifyPullReviewRequest(ctx, doer, issue, reviewer, isAdd, comment)
76+
notification.NotifyPullRequestReviewRequest(ctx, doer, issue, reviewer, isAdd, comment)
7777
}
7878

7979
return comment, err
@@ -260,7 +260,7 @@ func TeamReviewRequest(ctx context.Context, issue *issues_model.Issue, doer *use
260260
continue
261261
}
262262
comment.AssigneeID = member.ID
263-
notification.NotifyPullReviewRequest(ctx, doer, issue, member, isAdd, comment)
263+
notification.NotifyPullRequestReviewRequest(ctx, doer, issue, member, isAdd, comment)
264264
}
265265

266266
return comment, err

0 commit comments

Comments
 (0)