Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsvantesson committed Sep 30, 2019
1 parent e2080e8 commit 9da17c1
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions models/repo_collaboration.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,15 @@ func (repo *Repository) addCollaborator(e Engine, u *User) error {
func (repo *Repository) AddCollaborator(u *User) error {
sess := x.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
}

if err = repo.addCollaborator(sess, u); err != nil {
if err := sess.Begin(); err != nil {
return err
}

if err = sess.Commit(); err != nil {
if err := repo.addCollaborator(sess, u); err != nil {
return err
}

return nil
return sess.Commit()
}

func (repo *Repository) getCollaborations(e Engine) ([]*Collaboration, error) {
Expand Down Expand Up @@ -148,19 +144,15 @@ func (repo *Repository) changeCollaborationAccessMode(e Engine, uid int64, mode
func (repo *Repository) ChangeCollaborationAccessMode(uid int64, mode AccessMode) error {
sess := x.NewSession()
defer sess.Close()
if err = sess.Begin(); err != nil {
return err
}

if err = repo.changeCollaborationAccessMode(sess, uid, mode); err != nil {
if err := sess.Begin(); err != nil {
return err
}

if err = sess.Commit(); err != nil {
if err := repo.changeCollaborationAccessMode(sess, uid, mode); err != nil {
return err
}

return nil
return sess.Commit()
}

// DeleteCollaboration removes collaboration relation between the user and repository.
Expand Down

0 comments on commit 9da17c1

Please sign in to comment.