Skip to content

Commit d20e49f

Browse files
authored
Merge branch 'main' into update-i.8713187.xyz/google/go-github
2 parents 3d7a341 + ff2f479 commit d20e49f

38 files changed

+466
-278
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

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/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
}

modules/git/commit.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func (c *Commit) SearchCommits(opts SearchCommitsOptions) ([]*Commit, error) {
291291

292292
// GetFilesChangedSinceCommit get all changed file names between pastCommit to current revision
293293
func (c *Commit) GetFilesChangedSinceCommit(pastCommit string) ([]string, error) {
294-
return c.repo.getFilesChanged(pastCommit, c.ID.String())
294+
return c.repo.GetFilesChangedBetween(pastCommit, c.ID.String())
295295
}
296296

297297
// FileChangedSinceCommit Returns true if the file given has changed since the the past commit

modules/git/repo_commit.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,6 @@ func (repo *Repository) searchCommits(id SHA1, opts SearchCommitsOptions) ([]*Co
182182
return repo.parsePrettyFormatLogToList(bytes.TrimSuffix(stdout, []byte{'\n'}))
183183
}
184184

185-
func (repo *Repository) getFilesChanged(id1, id2 string) ([]string, error) {
186-
stdout, _, err := NewCommand(repo.Ctx, "diff", "--name-only").AddDynamicArguments(id1, id2).RunStdBytes(&RunOpts{Dir: repo.Path})
187-
if err != nil {
188-
return nil, err
189-
}
190-
return strings.Split(string(stdout), "\n"), nil
191-
}
192-
193185
// FileChangedBetweenCommits Returns true if the file changed between commit IDs id1 and id2
194186
// You must ensure that id1 and id2 are valid commit ids.
195187
func (repo *Repository) FileChangedBetweenCommits(filename, id1, id2 string) (bool, error) {

0 commit comments

Comments
 (0)