Skip to content

Commit e9d3619

Browse files
authored
Merge branch 'main' into clean-template-helper
2 parents 37f5766 + 17623bb commit e9d3619

Some content is hidden

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

51 files changed

+569
-253
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM golang:1.20-alpine3.17 AS build-env
2+
FROM docker.io/library/golang:1.20-alpine3.17 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}
@@ -23,7 +23,7 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2323
# Begin env-to-ini build
2424
RUN go build contrib/environment-to-ini/environment-to-ini.go
2525

26-
FROM alpine:3.17
26+
FROM docker.io/library/alpine:3.17
2727
LABEL maintainer="[email protected]"
2828

2929
EXPOSE 22 3000

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#Build stage
2-
FROM golang:1.20-alpine3.17 AS build-env
2+
FROM docker.io/library/golang:1.20-alpine3.17 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}
@@ -23,7 +23,7 @@ RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
2323
# Begin env-to-ini build
2424
RUN go build contrib/environment-to-ini/environment-to-ini.go
2525

26-
FROM alpine:3.17
26+
FROM docker.io/library/alpine:3.17
2727
LABEL maintainer="[email protected]"
2828

2929
EXPOSE 2222 3000

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ generate-go: $(TAGS_PREREQ)
747747

748748
.PHONY: security-check
749749
security-check:
750-
go run $(GOVULNCHECK_PACKAGE) -v ./...
750+
go run $(GOVULNCHECK_PACKAGE) ./...
751751

752752
$(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
753753
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@

docs/content/doc/usage/push-options.en-us.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/content/doc/usage/push-options.zh-tw.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

docs/content/doc/usage/push-to-create.en-us.md renamed to docs/content/doc/usage/push.en-us.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,51 @@
11
---
22
date: "2020-07-06T16:00:00+02:00"
3-
title: "Push To Create"
4-
slug: "push-to-create"
3+
title: "Usage: Push"
4+
slug: "push"
55
weight: 15
66
toc: false
77
draft: false
88
menu:
99
sidebar:
1010
parent: "usage"
11-
name: "Push To Create"
11+
name: "Push"
1212
weight: 15
13-
identifier: "push-to-create"
13+
identifier: "push"
1414
---
1515

16+
**Table of Contents**
17+
18+
{{< toc >}}
19+
20+
There are some additional features when pushing commits to Gitea server.
21+
22+
# Open PR through Push
23+
24+
When you push commits to a non-default branch for the first time,
25+
you will receive a link you can click on to visit the compare page of your branch compared to your main branch.
26+
From there, it's easy to create a pull request, even if you want to target another branch.
27+
28+
![Gitea Push Hint](/gitea-push-hint.png)
29+
30+
# Push Options
31+
32+
In Gitea `1.13`, support for some [push options](https://git-scm.com/docs/git-push#Documentation/git-push.txt--oltoptiongt)
33+
were added.
34+
35+
## Supported Options
36+
37+
- `repo.private` (true|false) - Change the repository's visibility.
38+
39+
This is particularly useful when combined with push-to-create.
40+
41+
- `repo.template` (true|false) - Change whether the repository is a template.
42+
43+
Example of changing a repository's visibility to public:
44+
45+
```shell
46+
git push -o repo.private=false -u origin main
47+
```
48+
1649
# Push To Create
1750

1851
Push to create is a feature that allows you to push to a repository that does not exist yet in Gitea. This is useful for automation and for allowing users to create repositories without having to go through the web interface. This feature is disabled by default.
@@ -35,6 +68,4 @@ git push -u origin main
3568

3669
This assumes you are using an SSH remote, but you can also use HTTPS remotes as well.
3770

38-
## Push options (bonus)
39-
40-
Push-to-create will default to the visibility defined by `DEFAULT_PUSH_CREATE_PRIVATE` in `app.ini`. To explicitly set the visibility, you can use a [push option]({{< relref "doc/usage/push-options.en-us.md" >}}).
71+
Push-to-create will default to the visibility defined by `DEFAULT_PUSH_CREATE_PRIVATE` in `app.ini`.

docs/content/doc/usage/push.zh-tw.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
date: "2020-07-06T16:00:00+02:00"
3+
title: "使用: Push"
4+
slug: "push"
5+
weight: 15
6+
toc: false
7+
draft: false
8+
menu:
9+
sidebar:
10+
parent: "usage"
11+
name: "Push"
12+
weight: 15
13+
identifier: "push"
14+
---
15+
16+
**Table of Contents**
17+
18+
{{< toc >}}
19+
20+
There are some additional features when pushing commits to Gitea server.
21+
22+
# Push Merge Hint
23+
24+
When you pushing commits to a non-default branch, you will get an information from
25+
Gitea which is a link, you can click the link and go to a compare page. It's a quick
26+
way to create a pull request or a code review yourself in the Gitea UI.
27+
28+
![Gitea Push Hint](/gitea-push-hint.png)
29+
30+
# Push Options
31+
32+
Gitea 從 `1.13` 版開始支援某些 [push options](https://git-scm.com/docs/git-push#Documentation/git-push.txt--oltoptiongt)
33+
34+
35+
## 支援的 Options
36+
37+
- `repo.private` (true|false) - 修改儲存庫的可見性。
38+
39+
與 push-to-create 一起使用時特別有用。
40+
41+
- `repo.template` (true|false) - 修改儲存庫是否為範本儲存庫。
42+
43+
以下範例修改儲存庫的可見性為公開:
44+
45+
```shell
46+
git push -o repo.private=false -u origin main
47+
```
48+
49+
# Push To Create
50+
51+
Push to create is a feature that allows you to push to a repository that does not exist yet in Gitea. This is useful for automation and for allowing users to create repositories without having to go through the web interface. This feature is disabled by default.
52+
53+
## Enabling Push To Create
54+
55+
In the `app.ini` file, set `ENABLE_PUSH_CREATE_USER` to `true` and `ENABLE_PUSH_CREATE_ORG` to `true` if you want to allow users to create repositories in their own user account and in organizations they are a member of respectively. Restart Gitea for the changes to take effect. You can read more about these two options in the [Configuration Cheat Sheet]({{< relref "doc/administration/config-cheat-sheet.zh-tw.md#repository-repository" >}}).
56+
57+
## Using Push To Create
58+
59+
Assuming you have a git repository in the current directory, you can push to a repository that does not exist yet in Gitea by running the following command:
60+
61+
```shell
62+
# Add the remote you want to push to
63+
git remote add origin git@{domain}:{username}/{repo name that does not exist yet}.git
64+
65+
# push to the remote
66+
git push -u origin main
67+
```
68+
69+
This assumes you are using an SSH remote, but you can also use HTTPS remotes as well.

docs/static/gitea-push-hint.png

412 KB
Loading

models/actions/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ type ActionRun struct {
3636
TriggerUser *user_model.User `xorm:"-"`
3737
Ref string
3838
CommitSHA string
39-
IsForkPullRequest bool
39+
IsForkPullRequest bool // If this is triggered by a PR from a forked repository or an untrusted user, we need to check if it is approved and limit permissions when running the workflow.
4040
NeedApproval bool // may need approval if it's a fork pull request
4141
ApprovedBy int64 `xorm:"index"` // who approved
4242
Event webhook_module.HookEventType

models/fixtures/org_user.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,9 @@
7575
uid: 31
7676
org_id: 19
7777
is_public: true
78+
79+
-
80+
id: 14
81+
uid: 5
82+
org_id: 23
83+
is_public: false

models/fixtures/team.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,15 @@
172172
num_repos: 0
173173
num_members: 0
174174
includes_all_repositories: false
175-
can_create_org_repo: true
175+
can_create_org_repo: true
176+
177+
-
178+
id: 17
179+
org_id: 23
180+
lower_name: team14writeauth
181+
name: team14WriteAuth
182+
authorize: 2 # write
183+
num_repos: 0
184+
num_members: 1
185+
includes_all_repositories: false
186+
can_create_org_repo: true

models/fixtures/team_unit.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,9 @@
268268
team_id: 9
269269
type: 1 # code
270270
access_mode: 1
271+
272+
-
273+
id: 46
274+
team_id: 17
275+
type: 9 # package
276+
access_mode: 0

models/fixtures/team_user.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,9 @@
9999
org_id: 3
100100
team_id: 14
101101
uid: 2
102+
103+
-
104+
id: 18
105+
org_id: 23
106+
team_id: 17
107+
uid: 5

models/fixtures/user.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,8 @@
844844
num_following: 0
845845
num_stars: 0
846846
num_repos: 2
847-
num_teams: 1
848-
num_members: 0
847+
num_teams: 2
848+
num_members: 1
849849
visibility: 2
850850
repo_admin_change_team_access: false
851851
theme: ""

models/organization/org_test.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,25 +212,31 @@ func TestGetOrgUsersByUserID(t *testing.T) {
212212

213213
orgUsers, err := organization.GetOrgUsersByUserID(5, &organization.SearchOrganizationsOptions{All: true})
214214
assert.NoError(t, err)
215-
if assert.Len(t, orgUsers, 2) {
215+
if assert.Len(t, orgUsers, 3) {
216216
assert.Equal(t, organization.OrgUser{
217217
ID: orgUsers[0].ID,
218-
OrgID: 6,
218+
OrgID: 23,
219219
UID: 5,
220-
IsPublic: true,
220+
IsPublic: false,
221221
}, *orgUsers[0])
222222
assert.Equal(t, organization.OrgUser{
223223
ID: orgUsers[1].ID,
224+
OrgID: 6,
225+
UID: 5,
226+
IsPublic: true,
227+
}, *orgUsers[1])
228+
assert.Equal(t, organization.OrgUser{
229+
ID: orgUsers[2].ID,
224230
OrgID: 7,
225231
UID: 5,
226232
IsPublic: false,
227-
}, *orgUsers[1])
233+
}, *orgUsers[2])
228234
}
229235

230236
publicOrgUsers, err := organization.GetOrgUsersByUserID(5, &organization.SearchOrganizationsOptions{All: false})
231237
assert.NoError(t, err)
232238
assert.Len(t, publicOrgUsers, 1)
233-
assert.Equal(t, *orgUsers[0], *publicOrgUsers[0])
239+
assert.Equal(t, *orgUsers[1], *publicOrgUsers[0])
234240

235241
orgUsers, err = organization.GetOrgUsersByUserID(1, &organization.SearchOrganizationsOptions{All: true})
236242
assert.NoError(t, err)

models/repo/user_repo.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,25 @@ func GetReviewers(ctx context.Context, repo *Repository, doerID, posterID int64)
155155
return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderByName()).Find(&users)
156156
}
157157

158-
// GetIssuePosters returns all users that have authored an issue/pull request for the given repository
159-
func GetIssuePosters(ctx context.Context, repo *Repository, isPull bool) ([]*user_model.User, error) {
160-
users := make([]*user_model.User, 0, 8)
158+
// GetIssuePostersWithSearch returns users with limit of 30 whose username started with prefix that have authored an issue/pull request for the given repository
159+
// If isShowFullName is set to true, also include full name prefix search
160+
func GetIssuePostersWithSearch(ctx context.Context, repo *Repository, isPull bool, search string, isShowFullName bool) ([]*user_model.User, error) {
161+
users := make([]*user_model.User, 0, 30)
162+
var prefixCond builder.Cond = builder.Like{"name", search + "%"}
163+
if isShowFullName {
164+
prefixCond = prefixCond.Or(builder.Like{"full_name", "%" + search + "%"})
165+
}
166+
161167
cond := builder.In("`user`.id",
162168
builder.Select("poster_id").From("issue").Where(
163169
builder.Eq{"repo_id": repo.ID}.
164170
And(builder.Eq{"is_pull": isPull}),
165-
).GroupBy("poster_id"),
166-
)
167-
return users, db.GetEngine(ctx).Where(cond).OrderBy(user_model.GetOrderByName()).Find(&users)
171+
).GroupBy("poster_id")).And(prefixCond)
172+
173+
return users, db.GetEngine(ctx).
174+
Where(cond).
175+
Cols("id", "name", "full_name", "avatar", "avatar_email", "use_custom_avatar").
176+
OrderBy("name").
177+
Limit(30).
178+
Find(&users)
168179
}

0 commit comments

Comments
 (0)