Skip to content

Commit 1cb4407

Browse files
authored
Merge branch 'main' into update-webhook-doc
2 parents 1094aa5 + bd613c7 commit 1cb4407

File tree

14 files changed

+142
-32
lines changed

14 files changed

+142
-32
lines changed

contrib/fhs-compliant-script/gitea

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ if [ -z "$APP_INI_SET" ]; then
3737
fi
3838

3939
# Provide FHS compliant defaults to
40-
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" "$GITEA" $CONF_ARG "$@"
40+
exec -a "$0" GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" "$GITEA" $CONF_ARG "$@"
4141

4242

docs/content/doc/usage/command-line.en-us.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,22 @@ Admin operations:
7777
- One of `--id`, `--username` or `--email` is required. If more than one is provided then all have to match.
7878
- Examples:
7979
- `gitea admin user delete --id 1`
80-
- `create`: - Options: - `--name value`: Username. Required. As of gitea 1.9.0, use the `--username` flag instead. - `--username value`: Username. Required. New in gitea 1.9.0. - `--password value`: Password. Required. - `--email value`: Email. Required. - `--admin`: If provided, this makes the user an admin. Optional. - `--access-token`: If provided, an access token will be created for the user. Optional. (default: false). - `--must-change-password`: If provided, the created user will be required to choose a newer password after
81-
the initial login. Optional. (default: true). - `--random-password`: If provided, a randomly generated password will be used as the password of
82-
the created user. The value of `--password` will be discarded. Optional. - `--random-password-length`: If provided, it will be used to configure the length of the randomly
83-
generated password. Optional. (default: 12) - Examples: - `gitea admin user create --username myname --password asecurepassword --email [email protected]`
80+
- `create`:
81+
- Options:
82+
- `--name value`: Username. Required. As of gitea 1.9.0, use the `--username` flag instead.
83+
- `--username value`: Username. Required. New in gitea 1.9.0.
84+
- `--password value`: Password. Required.
85+
- `--email value`: Email. Required.
86+
- `--admin`: If provided, this makes the user an admin. Optional.
87+
- `--access-token`: If provided, an access token will be created for the user. Optional. (default: false).
88+
- `--must-change-password`: If provided, the created user will be required to choose a newer password after the
89+
initial login. Optional. (default: true).
90+
- `--random-password`: If provided, a randomly generated password will be used as the password of the created
91+
user. The value of `--password` will be discarded. Optional.
92+
- `--random-password-length`: If provided, it will be used to configure the length of the randomly generated
93+
password. Optional. (default: 12)
94+
- Examples:
95+
- `gitea admin user create --username myname --password asecurepassword --email [email protected]`
8496
- `change-password`:
8597
- Options:
8698
- `--username value`, `-u value`: Username. Required.

integrations/git_helper_for_declarative_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"os"
1414
"path"
1515
"path/filepath"
16+
"strconv"
1617
"strings"
1718
"testing"
1819
"time"
@@ -55,7 +56,7 @@ func createSSHUrl(gitPath string, u *url.URL) *url.URL {
5556
u2 := *u
5657
u2.Scheme = "ssh"
5758
u2.User = url.User("git")
58-
u2.Host = fmt.Sprintf("%s:%d", setting.SSH.ListenHost, setting.SSH.ListenPort)
59+
u2.Host = net.JoinHostPort(setting.SSH.ListenHost, strconv.Itoa(setting.SSH.ListenPort))
5960
u2.Path = gitPath
6061
return &u2
6162
}

models/migrations/v161.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
package migrations
66

77
import (
8+
"context"
9+
810
"xorm.io/xorm"
911
)
1012

@@ -42,8 +44,17 @@ func convertTaskTypeToString(x *xorm.Engine) error {
4244
return err
4345
}
4446

47+
// to keep the migration could be rerun
48+
exist, err := x.Dialect().IsColumnExist(x.DB(), context.Background(), "hook_task", "type")
49+
if err != nil {
50+
return err
51+
}
52+
if !exist {
53+
return nil
54+
}
55+
4556
for i, s := range hookTaskTypes {
46-
if _, err := x.Exec("UPDATE hook_task set typ = ? where type=?", s, i); err != nil {
57+
if _, err := x.Exec("UPDATE hook_task set typ = ? where `type`=?", s, i); err != nil {
4758
return err
4859
}
4960
}

modules/convert/git_commit.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,9 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string]
147147

148148
return &api.Commit{
149149
CommitMeta: &api.CommitMeta{
150-
URL: repo.APIURL() + "/git/commits/" + commit.ID.String(),
151-
SHA: commit.ID.String(),
150+
URL: repo.APIURL() + "/git/commits/" + commit.ID.String(),
151+
SHA: commit.ID.String(),
152+
Created: commit.Committer.When,
152153
},
153154
HTMLURL: repo.HTMLURL() + "/commit/" + commit.ID.String(),
154155
RepoCommit: &api.RepoCommit{
@@ -169,8 +170,9 @@ func ToCommit(repo *models.Repository, commit *git.Commit, userCache map[string]
169170
},
170171
Message: commit.Message(),
171172
Tree: &api.CommitMeta{
172-
URL: repo.APIURL() + "/git/trees/" + commit.ID.String(),
173-
SHA: commit.ID.String(),
173+
URL: repo.APIURL() + "/git/trees/" + commit.ID.String(),
174+
SHA: commit.ID.String(),
175+
Created: commit.Committer.When,
174176
},
175177
},
176178
Author: apiAuthor,

modules/setting/log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func getLogLevel(section *ini.Section, key string, defaultValue log.Level) log.L
120120
}
121121

122122
func getStacktraceLogLevel(section *ini.Section, key string, defaultValue string) string {
123-
value := section.Key(key).MustString("none")
123+
value := section.Key(key).MustString(defaultValue)
124124
return log.FromString(value).String()
125125
}
126126

modules/ssh/ssh.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"os"
1818
"os/exec"
1919
"path/filepath"
20+
"strconv"
2021
"strings"
2122
"sync"
2223
"syscall"
@@ -264,7 +265,7 @@ func sshConnectionFailed(conn net.Conn, err error) {
264265
// Listen starts a SSH server listens on given port.
265266
func Listen(host string, port int, ciphers []string, keyExchanges []string, macs []string) {
266267
srv := ssh.Server{
267-
Addr: fmt.Sprintf("%s:%d", host, port),
268+
Addr: net.JoinHostPort(host, strconv.Itoa(port)),
268269
PublicKeyHandler: publicKeyHandler,
269270
Handler: sessionHandler,
270271
ServerConfigCallback: func(ctx ssh.Context) *gossh.ServerConfig {

options/locale/locale_en-US.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ lfs_path = Git LFS Root Path
149149
lfs_path_helper = Files tracked by Git LFS will be stored in this directory. Leave empty to disable.
150150
run_user = Run As Username
151151
run_user_helper = Enter the operating system username that Gitea runs as. Note that this user must have access to the repository root path.
152-
domain = SSH Server Domain
153-
domain_helper = Domain or host address for SSH clone URLs.
152+
domain = Server Domain
153+
domain_helper = Domain or host address for the server.
154154
ssh_port = SSH Server Port
155155
ssh_port_helper = Port number your SSH server listens on. Leave empty to disable.
156156
http_port = Gitea HTTP Listen Port
@@ -2547,7 +2547,7 @@ config.app_ver = Gitea Version
25472547
config.app_url = Gitea Base URL
25482548
config.custom_conf = Configuration File Path
25492549
config.custom_file_root_path = "Custom File Root Path"
2550-
config.domain = SSH Server Domain
2550+
config.domain = Server Domain
25512551
config.offline_mode = Local Mode
25522552
config.disable_router_log = Disable Router Log
25532553
config.run_user = Run As Username
@@ -2563,7 +2563,7 @@ config.reverse_auth_user = Reverse Authentication User
25632563
config.ssh_config = SSH Configuration
25642564
config.ssh_enabled = Enabled
25652565
config.ssh_start_builtin_server = Use Built-In Server
2566-
config.ssh_domain = Server Domain
2566+
config.ssh_domain = SSH Server Domain
25672567
config.ssh_port = Port
25682568
config.ssh_listen_port = Listen Port
25692569
config.ssh_root_path = Root Path

options/locale/locale_ja-JP.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ form.name_chars_not_allowed=ユーザー名 '%s' には無効な文字が含ま
490490
[settings]
491491
profile=プロフィール
492492
account=アカウント
493+
appearance=外観
493494
password=パスワード
494495
security=セキュリティ
495496
avatar=アバター
@@ -514,7 +515,9 @@ website=Webサイト
514515
location=場所
515516
update_theme=テーマを更新
516517
update_profile=プロフィール更新
518+
update_language=言語を更新
517519
update_language_not_found=言語 '%s' は利用できません。
520+
update_language_success=言語が更新されました。
518521
update_profile_success=プロフィールを更新しました。
519522
change_username=ユーザー名を変更しました。
520523
change_username_prompt=注: ユーザー名を変更すると、アカウントのURLも変わります。
@@ -2783,6 +2786,7 @@ publish_release=`が <a href="%[1]s">%[3]s</a> の <a href="%[1]s/releases/tag/%
27832786
review_dismissed=`が <b>%[4]s</b> の <a href="%[1]s/pulls/%[2]s">%[3]s#%[2]s</a> へのレビューを棄却しました`
27842787
review_dismissed_reason=理由:
27852788
create_branch=が <a href="%[1]s">%[4]s</a> にブランチ <a href="%[1]s/src/branch/%[2]s">%[3]s</a> を作成しました
2789+
starred_repo=が <a href="%[1]s">%[2]s</a> にスターをつけました
27862790
watched_repo=が <a href="%[1]s">%[2]s</a> のウォッチを開始しました
27872791

27882792
[tool]

routers/init.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ package routers
66

77
import (
88
"context"
9+
"net"
910
"reflect"
1011
"runtime"
12+
"strconv"
1113
"strings"
1214

1315
"code.gitea.io/gitea/models"
@@ -155,7 +157,9 @@ func GlobalInit(ctx context.Context) {
155157

156158
if setting.SSH.StartBuiltinServer {
157159
ssh.Listen(setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)
158-
log.Info("SSH server started on %s:%d. Cipher list (%v), key exchange algorithms (%v), MACs (%v)", setting.SSH.ListenHost, setting.SSH.ListenPort, setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)
160+
log.Info("SSH server started on %s. Cipher list (%v), key exchange algorithms (%v), MACs (%v)",
161+
net.JoinHostPort(setting.SSH.ListenHost, strconv.Itoa(setting.SSH.ListenPort)),
162+
setting.SSH.ServerCiphers, setting.SSH.ServerKeyExchanges, setting.SSH.ServerMACs)
159163
} else {
160164
ssh.Unused()
161165
}

routers/web/repo/issue.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,9 +2577,33 @@ func combineLabelComments(issue *models.Issue) {
25772577
if cur.Label != nil { // now cur MUST be label comment
25782578
if prev.Type == models.CommentTypeLabel { // we can combine them only prev is a label comment
25792579
if cur.Content != "1" {
2580-
prev.RemovedLabels = append(prev.RemovedLabels, cur.Label)
2580+
// remove labels from the AddedLabels list if the label that was removed is already
2581+
// in this list, and if it's not in this list, add the label to RemovedLabels
2582+
addedAndRemoved := false
2583+
for i, label := range prev.AddedLabels {
2584+
if cur.Label.ID == label.ID {
2585+
prev.AddedLabels = append(prev.AddedLabels[:i], prev.AddedLabels[i+1:]...)
2586+
addedAndRemoved = true
2587+
break
2588+
}
2589+
}
2590+
if !addedAndRemoved {
2591+
prev.RemovedLabels = append(prev.RemovedLabels, cur.Label)
2592+
}
25812593
} else {
2582-
prev.AddedLabels = append(prev.AddedLabels, cur.Label)
2594+
// remove labels from the RemovedLabels list if the label that was added is already
2595+
// in this list, and if it's not in this list, add the label to AddedLabels
2596+
removedAndAdded := false
2597+
for i, label := range prev.RemovedLabels {
2598+
if cur.Label.ID == label.ID {
2599+
prev.RemovedLabels = append(prev.RemovedLabels[:i], prev.RemovedLabels[i+1:]...)
2600+
removedAndAdded = true
2601+
break
2602+
}
2603+
}
2604+
if !removedAndAdded {
2605+
prev.AddedLabels = append(prev.AddedLabels, cur.Label)
2606+
}
25832607
}
25842608
prev.CreatedUnix = cur.CreatedUnix
25852609
// remove the current comment since it has been combined to prev comment

routers/web/repo/issue_test.go

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,7 @@ func TestCombineLabelComments(t *testing.T) {
5151
PosterID: 1,
5252
Content: "1",
5353
CreatedUnix: 0,
54-
AddedLabels: []*models.Label{
55-
{
56-
Name: "kind/bug",
57-
},
58-
},
59-
RemovedLabels: []*models.Label{
60-
{
61-
Name: "kind/bug",
62-
},
63-
},
54+
AddedLabels: []*models.Label{},
6455
Label: &models.Label{
6556
Name: "kind/bug",
6657
},
@@ -310,6 +301,66 @@ func TestCombineLabelComments(t *testing.T) {
310301
},
311302
},
312303
},
304+
{
305+
name: "kase 6",
306+
beforeCombined: []*models.Comment{
307+
{
308+
Type: models.CommentTypeLabel,
309+
PosterID: 1,
310+
Content: "1",
311+
Label: &models.Label{
312+
Name: "kind/bug",
313+
},
314+
CreatedUnix: 0,
315+
},
316+
{
317+
Type: models.CommentTypeLabel,
318+
PosterID: 1,
319+
Content: "1",
320+
Label: &models.Label{
321+
Name: "reviewed/confirmed",
322+
},
323+
CreatedUnix: 0,
324+
},
325+
{
326+
Type: models.CommentTypeLabel,
327+
PosterID: 1,
328+
Content: "",
329+
Label: &models.Label{
330+
Name: "kind/bug",
331+
},
332+
CreatedUnix: 0,
333+
},
334+
{
335+
Type: models.CommentTypeLabel,
336+
PosterID: 1,
337+
Content: "1",
338+
Label: &models.Label{
339+
Name: "kind/feature",
340+
},
341+
CreatedUnix: 0,
342+
},
343+
},
344+
afterCombined: []*models.Comment{
345+
{
346+
Type: models.CommentTypeLabel,
347+
PosterID: 1,
348+
Content: "1",
349+
Label: &models.Label{
350+
Name: "kind/bug",
351+
},
352+
AddedLabels: []*models.Label{
353+
{
354+
Name: "reviewed/confirmed",
355+
},
356+
{
357+
Name: "kind/feature",
358+
},
359+
},
360+
CreatedUnix: 0,
361+
},
362+
},
363+
},
313364
}
314365

315366
for _, kase := range kases {

templates/base/delete_modal_actions.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="actions">
22
<div class="ui red basic inverted cancel button">
3-
{{svg "octicon-trash"}}
3+
{{svg "octicon-x"}}
44
{{.i18n.Tr "modal.no"}}
55
</div>
66
<div class="ui green basic inverted ok button">

templates/repo/issue/view_content/comments.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@
158158
{{if eq .RefAction 3}}</del>{{end}}
159159

160160
<div class="detail">
161-
<span class="text grey"><a href="{{.RefIssueHTMLURL}}"><b>{{.RefIssueTitle | Str2html}}</b> {{.RefIssueIdent | Str2html}}</a></span>
161+
<span class="text grey"><a href="{{.RefIssueHTMLURL}}"><b>{{.RefIssueTitle}}</b> {{.RefIssueIdent}}</a></span>
162162
</div>
163163
</div>
164164
{{else if eq .Type 4}}

0 commit comments

Comments
 (0)