diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/external_login_user.go | 10 | ||||
-rw-r--r-- | models/issue_test.go | 8 | ||||
-rw-r--r-- | models/migrations/v23.go | 7 | ||||
-rw-r--r-- | models/org_team.go | 2 | ||||
-rw-r--r-- | models/user.go | 2 | ||||
-rw-r--r-- | models/user_follow.go | 1 | ||||
-rw-r--r-- | models/user_openid.go | 9 | ||||
-rw-r--r-- | models/user_openid_test.go | 8 | ||||
-rw-r--r-- | models/wiki.go | 6 |
9 files changed, 28 insertions, 25 deletions
diff --git a/models/external_login_user.go b/models/external_login_user.go index ade1b8a13b..b2680943c4 100644 --- a/models/external_login_user.go +++ b/models/external_login_user.go @@ -9,8 +9,8 @@ import "github.com/markbates/goth" // ExternalLoginUser makes the connecting between some existing user and additional external login sources type ExternalLoginUser struct { ExternalID string `xorm:"NOT NULL"` - UserID int64 `xorm:"NOT NULL"` - LoginSourceID int64 `xorm:"NOT NULL"` + UserID int64 `xorm:"NOT NULL"` + LoginSourceID int64 `xorm:"NOT NULL"` } // GetExternalLogin checks if a externalID in loginSourceID scope already exists @@ -67,8 +67,8 @@ func RemoveAccountLink(user *User, loginSourceID int64) (int64, error) { return deleted, err } -// RemoveAllAccountLinks will remove all external login sources for the given user -func RemoveAllAccountLinks(user *User) error { - _, err := x.Delete(&ExternalLoginUser{UserID: user.ID}) +// removeAllAccountLinks will remove all external login sources for the given user +func removeAllAccountLinks(e Engine, user *User) error { + _, err := e.Delete(&ExternalLoginUser{UserID: user.ID}) return err } diff --git a/models/issue_test.go b/models/issue_test.go index 52724d07d4..71ce92ea7e 100644 --- a/models/issue_test.go +++ b/models/issue_test.go @@ -67,8 +67,10 @@ func TestGetParticipantsByIssueID(t *testing.T) { checkPartecipants := func(issueID int64, userIDs []int) { partecipants, err := GetParticipantsByIssueID(issueID) if assert.NoError(t, err) { - partecipantsIDs := make([]int,len(partecipants)) - for i,u := range partecipants { partecipantsIDs[i] = int(u.ID) } + partecipantsIDs := make([]int, len(partecipants)) + for i, u := range partecipants { + partecipantsIDs[i] = int(u.ID) + } sort.Ints(partecipantsIDs) sort.Ints(userIDs) assert.Equal(t, userIDs, partecipantsIDs) @@ -79,6 +81,6 @@ func TestGetParticipantsByIssueID(t *testing.T) { // User 1 is issue1 poster (see fixtures/issue.yml) // User 2 only labeled issue1 (see fixtures/comment.yml) // Users 3 and 5 made actual comments (see fixtures/comment.yml) - checkPartecipants(1, []int{3,5}) + checkPartecipants(1, []int{3, 5}) } diff --git a/models/migrations/v23.go b/models/migrations/v23.go index efde684104..4aadf7ef0d 100644 --- a/models/migrations/v23.go +++ b/models/migrations/v23.go @@ -12,12 +12,11 @@ import ( // UserOpenID is the list of all OpenID identities of a user. type UserOpenID struct { - ID int64 `xorm:"pk autoincr"` - UID int64 `xorm:"INDEX NOT NULL"` - URI string `xorm:"UNIQUE NOT NULL"` + ID int64 `xorm:"pk autoincr"` + UID int64 `xorm:"INDEX NOT NULL"` + URI string `xorm:"UNIQUE NOT NULL"` } - func addUserOpenID(x *xorm.Engine) error { if err := x.Sync2(new(UserOpenID)); err != nil { return fmt.Errorf("Sync2: %v", err) diff --git a/models/org_team.go b/models/org_team.go index db25e61547..115e13feab 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -143,7 +143,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e if err != nil { return fmt.Errorf("getTeamUsersByTeamID: %v", err) } - for _, teamUser:= range teamUsers { + for _, teamUser := range teamUsers { has, err := hasAccess(e, teamUser.UID, repo, AccessModeRead) if err != nil { return err diff --git a/models/user.go b/models/user.go index ad303d7535..72c21f4369 100644 --- a/models/user.go +++ b/models/user.go @@ -990,7 +990,7 @@ func deleteUser(e *xorm.Session, u *User) error { } // ***** START: ExternalLoginUser ***** - if err = RemoveAllAccountLinks(u); err != nil { + if err = removeAllAccountLinks(e, u); err != nil { return fmt.Errorf("ExternalLoginUser: %v", err) } // ***** END: ExternalLoginUser ***** diff --git a/models/user_follow.go b/models/user_follow.go index ac0cf0a8f3..2d64d05473 100644 --- a/models/user_follow.go +++ b/models/user_follow.go @@ -68,4 +68,3 @@ func UnfollowUser(userID, followID int64) (err error) { } return sess.Commit() } - diff --git a/models/user_openid.go b/models/user_openid.go index 18e847d89d..db84e2e08f 100644 --- a/models/user_openid.go +++ b/models/user_openid.go @@ -18,10 +18,10 @@ var ( // UserOpenID is the list of all OpenID identities of a user. type UserOpenID struct { - ID int64 `xorm:"pk autoincr"` - UID int64 `xorm:"INDEX NOT NULL"` - URI string `xorm:"UNIQUE NOT NULL"` - Show bool `xorm:"DEFAULT false"` + ID int64 `xorm:"pk autoincr"` + UID int64 `xorm:"INDEX NOT NULL"` + URI string `xorm:"UNIQUE NOT NULL"` + Show bool `xorm:"DEFAULT false"` } // GetUserOpenIDs returns all openid addresses that belongs to given user. @@ -122,4 +122,3 @@ func GetUserByOpenID(uri string) (*User, error) { return nil, ErrUserNotExist{0, uri, 0} } - diff --git a/models/user_openid_test.go b/models/user_openid_test.go index 74e3cf6f00..e4734cc428 100644 --- a/models/user_openid_test.go +++ b/models/user_openid_test.go @@ -52,14 +52,14 @@ func TestGetUserByOpenID(t *testing.T) { func TestToggleUserOpenIDVisibility(t *testing.T) { assert.NoError(t, PrepareTestDatabase()) oids, err := GetUserOpenIDs(int64(2)) - if ! assert.NoError(t, err) { + if !assert.NoError(t, err) { return } assert.Len(t, oids, 1) assert.True(t, oids[0].Show) err = ToggleUserOpenIDVisibility(oids[0].ID) - if ! assert.NoError(t, err) { + if !assert.NoError(t, err) { return } @@ -69,12 +69,12 @@ func TestToggleUserOpenIDVisibility(t *testing.T) { assert.False(t, oids[0].Show) } err = ToggleUserOpenIDVisibility(oids[0].ID) - if ! assert.NoError(t, err) { + if !assert.NoError(t, err) { return } oids, err = GetUserOpenIDs(int64(2)) - if ! assert.NoError(t, err) { + if !assert.NoError(t, err) { return } assert.Len(t, oids, 1) diff --git a/models/wiki.go b/models/wiki.go index 690da707c6..d864505d56 100644 --- a/models/wiki.go +++ b/models/wiki.go @@ -84,7 +84,11 @@ func (repo *Repository) LocalWikiPath() string { func (repo *Repository) UpdateLocalWiki() error { // Don't pass branch name here because it fails to clone and // checkout to a specific branch when wiki is an empty repository. - return UpdateLocalCopyBranch(repo.WikiPath(), repo.LocalWikiPath(), "") + var branch = "" + if com.IsExist(repo.LocalWikiPath()) { + branch = "master" + } + return UpdateLocalCopyBranch(repo.WikiPath(), repo.LocalWikiPath(), branch) } func discardLocalWikiChanges(localPath string) error { |