Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 'main' of https://github.com/go-gitea/gitea:
  [skip ci] Updated translations via Crowdin
  Improve the comment for 2FA filter in admin panel (go-gitea#18017)
  fix regression from go-gitea#16075 (go-gitea#18260)
  Prevent underline hover on cards (go-gitea#18259)
  Fix release link broken (go-gitea#18252)
  migrations: a deadline at January 1st, 1970 is valid (go-gitea#18237)
  • Loading branch information
zjjhot committed Jan 14, 2022
2 parents 5d238da + 8808293 commit 8abecc5
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 12 deletions.
43 changes: 37 additions & 6 deletions integrations/dump_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
base "code.gitea.io/gitea/modules/migration"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/migrations"

"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
)

func TestDumpRestore(t *testing.T) {
Expand Down Expand Up @@ -56,6 +58,8 @@ func TestDumpRestore(t *testing.T) {
var opts = migrations.MigrateOptions{
GitServiceType: structs.GiteaService,
Issues: true,
Labels: true,
Milestones: true,
Comments: true,
AuthToken: token,
CloneAddr: repo.CloneLink().HTTPS,
Expand All @@ -68,7 +72,7 @@ func TestDumpRestore(t *testing.T) {
// Verify desired side effects of the dump
//
d := filepath.Join(basePath, repo.OwnerName, repo.Name)
for _, f := range []string{"repo.yml", "topic.yml", "issue.yml"} {
for _, f := range []string{"repo.yml", "topic.yml", "label.yml", "milestone.yml", "issue.yml"} {
assert.FileExists(t, filepath.Join(d, f))
}

Expand All @@ -77,7 +81,7 @@ func TestDumpRestore(t *testing.T) {
//

newreponame := "restoredrepo"
err = migrations.RestoreRepository(ctx, d, repo.OwnerName, newreponame, []string{"issues", "comments"})
err = migrations.RestoreRepository(ctx, d, repo.OwnerName, newreponame, []string{"labels", "milestones", "issues", "comments"})
assert.NoError(t, err)

newrepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: newreponame}).(*repo_model.Repository)
Expand All @@ -94,11 +98,38 @@ func TestDumpRestore(t *testing.T) {
// Verify the dump of restoredrepo is the same as the dump of repo1
//
newd := filepath.Join(basePath, newrepo.OwnerName, newrepo.Name)
beforeBytes, err := os.ReadFile(filepath.Join(d, "repo.yml"))
for _, filename := range []string{"repo.yml", "label.yml", "milestone.yml"} {
beforeBytes, err := os.ReadFile(filepath.Join(d, filename))
assert.NoError(t, err)
before := strings.ReplaceAll(string(beforeBytes), reponame, newreponame)
after, err := os.ReadFile(filepath.Join(newd, filename))
assert.NoError(t, err)
assert.EqualValues(t, before, string(after))
}

beforeBytes, err := os.ReadFile(filepath.Join(d, "issue.yml"))
assert.NoError(t, err)
before := strings.ReplaceAll(string(beforeBytes), reponame, newreponame)
after, err := os.ReadFile(filepath.Join(newd, "repo.yml"))
var before = make([]*base.Issue, 0, 10)
assert.NoError(t, yaml.Unmarshal(beforeBytes, &before))
afterBytes, err := os.ReadFile(filepath.Join(newd, "issue.yml"))
assert.NoError(t, err)
assert.EqualValues(t, before, string(after))
var after = make([]*base.Issue, 0, 10)
assert.NoError(t, yaml.Unmarshal(afterBytes, &after))

assert.EqualValues(t, len(before), len(after))
if len(before) == len(after) {
for i := 0; i < len(before); i++ {
assert.EqualValues(t, before[i].Number, after[i].Number)
assert.EqualValues(t, before[i].Title, after[i].Title)
assert.EqualValues(t, before[i].Content, after[i].Content)
assert.EqualValues(t, before[i].Ref, after[i].Ref)
assert.EqualValues(t, before[i].Milestone, after[i].Milestone)
assert.EqualValues(t, before[i].State, after[i].State)
assert.EqualValues(t, before[i].IsLocked, after[i].IsLocked)
assert.EqualValues(t, before[i].Created, after[i].Created)
assert.EqualValues(t, before[i].Updated, after[i].Updated)
assert.EqualValues(t, before[i].Labels, after[i].Labels)
}
}
})
}
5 changes: 5 additions & 0 deletions models/fixtures/milestone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
is_closed: false
num_issues: 1
num_closed_issues: 0
deadline_unix: 253370764800

-
id: 2
Expand All @@ -15,6 +16,7 @@
is_closed: false
num_issues: 0
num_closed_issues: 0
deadline_unix: 253370764800

-
id: 3
Expand All @@ -24,6 +26,7 @@
is_closed: true
num_issues: 1
num_closed_issues: 0
deadline_unix: 253370764800

-
id: 4
Expand All @@ -33,6 +36,7 @@
is_closed: false
num_issues: 0
num_closed_issues: 0
deadline_unix: 253370764800

-
id: 5
Expand All @@ -42,3 +46,4 @@
is_closed: false
num_issues: 0
num_closed_issues: 0
deadline_unix: 253370764800
5 changes: 2 additions & 3 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -835,13 +835,12 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment
}
}
fallthrough
case CommentTypeReview:
fallthrough
case CommentTypeComment:
if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
return err
}

fallthrough
case CommentTypeReview:
// Check attachments
attachments, err := repo_model.GetAttachmentsByUUIDs(ctx, opts.Attachments)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion models/user/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ func (opts *SearchUserOptions) toSearchQueryBase() *xorm.Session {
}

// 2fa filter uses LEFT JOIN to check whether a user has a 2fa record
// TODO: bad performance here, maybe there will be a column "is_2fa_enabled" in the future
// While using LEFT JOIN, sometimes the performance might not be good, but it won't be a problem now, such SQL is seldom executed.
// There are some possible methods to refactor this SQL in future when we really need to optimize the performance (but not now):
// (1) add a column in user table (2) add a setting value in user_setting table (3) use search engines (bleve/elasticsearch)
if opts.IsTwoFactorEnabled.IsTrue() {
cond = cond.And(builder.Expr("two_factor.uid IS NOT NULL"))
} else {
Expand Down
1 change: 0 additions & 1 deletion options/locale/locale_fi-FI.ini
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ AuthName=Luvan nimi
AdminEmail=Ylläpito sähköposti

NewBranchName=Uuden haaran nimi
CommitSummary=Commitin yhteenveto
CommitMessage=Commitin viesti
CommitChoice=Commitin valinta
TreeName=Tiedostopolku
Expand Down
3 changes: 3 additions & 0 deletions options/locale/locale_zh-TW.ini
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ oauth_signup_submit=完成帳戶
oauth_signin_tab=連結到現有帳戶
oauth_signin_title=登入以授權連結帳戶
oauth_signin_submit=連結帳戶
oauth.signin.error=處理授權請求時發生錯誤。如果這個問題持續發生,請聯絡網站管理員。
oauth.signin.error.access_denied=授權請求被拒絕。
oauth.signin.error.temporarily_unavailable=授權失敗,因為認證伺服器暫時無法使用。請稍後再試。
openid_connect_submit=連接
openid_connect_title=連接到現有帳戶
openid_connect_desc=所選的 OpenID URI 未知。在這裡連結一個新帳戶。
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/release/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<a href="{{.Publisher.HomeLink}}">{{.Publisher.Name}}</a>
</span>
{{ end }}
<span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}...{{.Target | PathEscapeSegments}}">{{$.i18n.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.i18n.Tr "repo.release.ahead.target" $.DefaultBranch}}</span>
<span class="ahead"><a href="{{$.RepoLink}}/compare/{{.TagName | PathEscapeSegments}}{{if .Target}}...{{.Target | PathEscapeSegments}}{{end}}">{{$.i18n.Tr "repo.release.ahead.commits" .NumCommitsBehind | Str2html}}</a> {{$.i18n.Tr "repo.release.ahead.target" $.DefaultBranch}}</span>
</p>
<div class="download">
{{if $.Permission.CanRead $.UnitTypeCode}}
Expand Down
1 change: 1 addition & 0 deletions web_src/less/_base.less
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ a.label,
.repository-menu a,
.ui.search .results a,
.ui .menu a,
.ui.cards a.card,
.issue-keyword a {
text-decoration: none !important;
}
Expand Down

0 comments on commit 8abecc5

Please sign in to comment.