Skip to content

Commit

Permalink
Merge branch into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Gitea committed Nov 20, 2019
2 parents b84622d + 2ab8c78 commit 668d3c0
Show file tree
Hide file tree
Showing 116 changed files with 4,021 additions and 3,192 deletions.
4 changes: 2 additions & 2 deletions docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,13 @@ Gitea can support Markup using external tools. The example below will add a mark

```ini
[markup.asciidoc]
ENABLED = false
ENABLED = true
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoc --out-file=- -"
IS_INPUT_FILE = false
```

- ENABLED: **false** Enable markup support.
- ENABLED: **false** Enable markup support; set to **true** to enable this renderer.
- FILE\_EXTENSIONS: **\<empty\>** List of file extensions that should be rendered by an external
command. Multiple extentions needs a comma as splitter.
- RENDER\_COMMAND: External command to render all matching extensions.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ require (
github.com/urfave/cli v1.20.0
github.com/willf/bitset v0.0.0-20180426185212-8ce1146b8621 // indirect
github.com/yohcop/openid-go v0.0.0-20160914080427-2c050d2dae53
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f
golang.org/x/net v0.0.0-20191101175033-0deb6923b6d9
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
golang.org/x/sys v0.0.0-20190910064555-bbd175535a8b
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ golang.org/x/crypto v0.0.0-20190617133340-57b3e21c3d56/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad h1:5E5raQxcv+6CZ11RrBYQe5WRbUIWpScjh0kvHZkZIrQ=
golang.org/x/crypto v0.0.0-20190927123631-a832865fa7ad/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f h1:kz4KIr+xcPUsI3VMoqWfPMvtnJ6MGfiVwsWSVzphMO4=
golang.org/x/crypto v0.0.0-20191117063200-497ca9f6d64f/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
Expand Down
2 changes: 2 additions & 0 deletions integrations/api_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@ func TestAPIOrgRepoCreate(t *testing.T) {
{ctxUserID: 1, orgName: "user3", repoName: "repo-admin", expectedStatus: http.StatusCreated},
{ctxUserID: 2, orgName: "user3", repoName: "repo-own", expectedStatus: http.StatusCreated},
{ctxUserID: 2, orgName: "user6", repoName: "repo-bad-org", expectedStatus: http.StatusForbidden},
{ctxUserID: 28, orgName: "user3", repoName: "repo-creator", expectedStatus: http.StatusCreated},
{ctxUserID: 28, orgName: "user6", repoName: "repo-not-creator", expectedStatus: http.StatusForbidden},
}

prepareTestEnv(t)
Expand Down
1 change: 1 addition & 0 deletions integrations/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestRenameReservedUsername(t *testing.T) {
"repo",
"template",
"user",
"search",
}

session := loginUser(t, "user2")
Expand Down
16 changes: 16 additions & 0 deletions models/fixtures/issue_watch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,19 @@
is_watching: false
created_unix: 946684800
updated_unix: 946684800

-
id: 3
user_id: 2
issue_id: 7
is_watching: true
created_unix: 946684800
updated_unix: 946684800

-
id: 4
user_id: 1
issue_id: 7
is_watching: false
created_unix: 946684800
updated_unix: 946684800
13 changes: 13 additions & 0 deletions models/fixtures/org_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,16 @@
uid: 24
org_id: 25
is_public: true

-
id: 9
uid: 28
org_id: 3
is_public: true

-
id: 10
uid: 28
org_id: 6
is_public: true

20 changes: 20 additions & 0 deletions models/fixtures/team.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,23 @@
authorize: 1 # read
num_repos: 0
num_members: 0

-
id: 12
org_id: 3
lower_name: team12creators
name: team12Creators
authorize: 3 # admin
num_repos: 0
num_members: 1
can_create_org_repo: true

-
id: 13
org_id: 6
lower_name: team13notcreators
name: team13NotCreators
authorize: 3 # admin
num_repos: 0
num_members: 1
can_create_org_repo: false
12 changes: 12 additions & 0 deletions models/fixtures/team_user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,15 @@
org_id: 25
team_id: 10
uid: 24

-
id: 13
org_id: 3
team_id: 12
uid: 28

-
id: 14
org_id: 6
team_id: 13
uid: 28
28 changes: 24 additions & 4 deletions models/fixtures/user.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
avatar: avatar3
avatar_email: [email protected]
num_repos: 3
num_members: 2
num_teams: 3
num_members: 3
num_teams: 4

-
id: 4
Expand Down Expand Up @@ -102,8 +102,8 @@
avatar: avatar6
avatar_email: [email protected]
num_repos: 0
num_members: 1
num_teams: 1
num_members: 2
num_teams: 2

-
id: 7
Expand Down Expand Up @@ -443,3 +443,23 @@
avatar: avatar27
avatar_email: [email protected]
num_repos: 2

-
id: 28
lower_name: user28
name: user28
full_name: "user27"
email: [email protected]
keep_email_private: true
passwd: 7d93daa0d1e6f2305cc8fa496847d61dc7320bb16262f9c55dd753480207234cdd96a93194e408341971742f4701772a025a # password
type: 0 # individual
salt: ZogKvWdyEx
is_admin: false
avatar: avatar28
avatar_email: [email protected]
num_repos: 0
num_stars: 0
num_followers: 0
num_following: 0
is_active: true

19 changes: 5 additions & 14 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,7 @@ func (issue *Issue) ChangeTitle(doer *User, oldTitle string) (err error) {
return fmt.Errorf("createComment: %v", err)
}

if err = issue.neuterCrossReferences(sess); err != nil {
return err
}

if err = issue.addCrossReferences(sess, doer); err != nil {
if err = issue.addCrossReferences(sess, doer, true); err != nil {
return err
}

Expand Down Expand Up @@ -810,10 +806,8 @@ func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
if err = updateIssueCols(sess, issue, "content"); err != nil {
return fmt.Errorf("UpdateIssueCols: %v", err)
}
if err = issue.neuterCrossReferences(sess); err != nil {
return err
}
if err = issue.addCrossReferences(sess, doer); err != nil {

if err = issue.addCrossReferences(sess, doer, true); err != nil {
return err
}

Expand Down Expand Up @@ -964,7 +958,7 @@ func newIssue(e *xorm.Session, doer *User, opts NewIssueOptions) (err error) {
if err = opts.Issue.loadAttributes(e); err != nil {
return err
}
return opts.Issue.addCrossReferences(e, doer)
return opts.Issue.addCrossReferences(e, doer, false)
}

// NewIssue creates new issue with labels for repository.
Expand Down Expand Up @@ -1598,13 +1592,10 @@ func UpdateIssue(issue *Issue) error {
if err := updateIssue(sess, issue); err != nil {
return err
}
if err := issue.neuterCrossReferences(sess); err != nil {
return err
}
if err := issue.loadPoster(sess); err != nil {
return err
}
if err := issue.addCrossReferences(sess, issue.Poster); err != nil {
if err := issue.addCrossReferences(sess, issue.Poster, true); err != nil {
return err
}
return sess.Commit()
Expand Down
7 changes: 2 additions & 5 deletions models/issue_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
}
}

if err = comment.addCrossReferences(e, opts.Doer); err != nil {
if err = comment.addCrossReferences(e, opts.Doer, false); err != nil {
return nil, err
}

Expand Down Expand Up @@ -882,10 +882,7 @@ func UpdateComment(c *Comment, doer *User) error {
if err := c.loadIssue(sess); err != nil {
return err
}
if err := c.neuterCrossReferences(sess); err != nil {
return err
}
if err := c.addCrossReferences(sess, doer); err != nil {
if err := c.addCrossReferences(sess, doer, true); err != nil {
return err
}
if err := sess.Commit(); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions models/issue_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func getIssueWatch(e Engine, userID, issueID int64) (iw *IssueWatch, exists bool
exists, err = e.
Where("user_id = ?", userID).
And("issue_id = ?", issueID).
And("is_watching = ?", true).
Get(iw)
return
}
Expand All @@ -80,6 +81,7 @@ func GetIssueWatchers(issueID int64) (IssueWatchList, error) {
func getIssueWatchers(e Engine, issueID int64) (watches IssueWatchList, err error) {
err = e.
Where("`issue_watch`.issue_id = ?", issueID).
And("`issue_watch`.is_watching = ?", true).
And("`user`.is_active = ?", true).
And("`user`.prohibit_login = ?", false).
Join("INNER", "`user`", "`user`.id = `issue_watch`.user_id").
Expand Down
23 changes: 15 additions & 8 deletions models/issue_watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@ func TestCreateOrUpdateIssueWatch(t *testing.T) {

assert.NoError(t, CreateOrUpdateIssueWatch(3, 1, true))
iw := AssertExistsAndLoadBean(t, &IssueWatch{UserID: 3, IssueID: 1}).(*IssueWatch)
assert.Equal(t, true, iw.IsWatching)
assert.True(t, iw.IsWatching)

assert.NoError(t, CreateOrUpdateIssueWatch(1, 1, false))
iw = AssertExistsAndLoadBean(t, &IssueWatch{UserID: 1, IssueID: 1}).(*IssueWatch)
assert.Equal(t, false, iw.IsWatching)
assert.False(t, iw.IsWatching)
}

func TestGetIssueWatch(t *testing.T) {
assert.NoError(t, PrepareTestDatabase())

_, exists, err := GetIssueWatch(9, 1)
assert.Equal(t, true, exists)
assert.True(t, exists)
assert.NoError(t, err)

_, exists, err = GetIssueWatch(2, 2)
assert.Equal(t, true, exists)
assert.False(t, exists)
assert.NoError(t, err)

_, exists, err = GetIssueWatch(3, 1)
assert.Equal(t, false, exists)
assert.False(t, exists)
assert.NoError(t, err)
}

Expand All @@ -44,13 +44,20 @@ func TestGetIssueWatchers(t *testing.T) {
iws, err := GetIssueWatchers(1)
assert.NoError(t, err)
// Watcher is inactive, thus 0
assert.Equal(t, 0, len(iws))
assert.Len(t, iws, 0)

iws, err = GetIssueWatchers(2)
assert.NoError(t, err)
assert.Equal(t, 1, len(iws))
// Watcher is explicit not watching
assert.Len(t, iws, 0)

iws, err = GetIssueWatchers(5)
assert.NoError(t, err)
assert.Equal(t, 0, len(iws))
// Issue has no Watchers
assert.Len(t, iws, 0)

iws, err = GetIssueWatchers(7)
assert.NoError(t, err)
// Issue has one watcher
assert.Len(t, iws, 1)
}
Loading

0 comments on commit 668d3c0

Please sign in to comment.