Team permission to create repository in organization (#8312)
* Add team permission setting to allow creating repo in organization. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add test case for creating repo when have team creation access. Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * build error: should omit comparison to bool constant Signed-off-by: David Svantesson <davidsvantesson@gmail.com> * Add comment on exported functions * Fix fixture consistency, fix existing unit tests * Fix boolean comparison in xorm query. * addCollaborator and changeCollaborationAccessMode separate steps More clear to use different if-cases. * Create and commit xorm session * fix * Add information of create repo permission in team sidebar * Add migration step * Clarify that repository creator will be administrator. * Fix some things after merge * Fix language text that use html * migrations file * Create repository permission -> Create repositories * fix merge * fix review comments
This commit is contained in:
parent
35c3ea952a
commit
69a255defb
27 changed files with 252 additions and 63 deletions
|
@ -1586,6 +1586,18 @@ func createRepository(e *xorm.Session, doer, u *User, repo *Repository) (err err
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if isAdmin, err := isUserRepoAdmin(e, repo, doer); err != nil {
|
||||
return fmt.Errorf("isUserRepoAdmin: %v", err)
|
||||
} else if !isAdmin {
|
||||
// Make creator repo admin if it wan't assigned automatically
|
||||
if err = repo.addCollaborator(e, doer); err != nil {
|
||||
return fmt.Errorf("AddCollaborator: %v", err)
|
||||
}
|
||||
if err = repo.changeCollaborationAccessMode(e, doer.ID, AccessModeAdmin); err != nil {
|
||||
return fmt.Errorf("ChangeCollaborationAccessMode: %v", err)
|
||||
}
|
||||
}
|
||||
} else if err = repo.recalculateAccesses(e); err != nil {
|
||||
// Organization automatically called this in addRepository method.
|
||||
return fmt.Errorf("recalculateAccesses: %v", err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue