AddRepository adds new repository to team of organization.
(repo *Repository)
| 131 | |
| 132 | // AddRepository adds new repository to team of organization. |
| 133 | func (t *Team) AddRepository(repo *Repository) (err error) { |
| 134 | if repo.OwnerID != t.OrgID { |
| 135 | return errors.New("Repository does not belong to organization") |
| 136 | } else if t.HasRepository(repo.ID) { |
| 137 | return nil |
| 138 | } |
| 139 | |
| 140 | sess := x.NewSession() |
| 141 | defer sess.Close() |
| 142 | if err = sess.Begin(); err != nil { |
| 143 | return err |
| 144 | } |
| 145 | |
| 146 | if err = t.addRepository(sess, repo); err != nil { |
| 147 | return err |
| 148 | } |
| 149 | |
| 150 | return sess.Commit() |
| 151 | } |
| 152 | |
| 153 | func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (err error) { |
| 154 | if err = removeTeamRepo(e, t.ID, repo.ID); err != nil { |
no test coverage detected