#2246 fully support of webhooks for pull request

This commit is contained in:
Unknwon 2016-08-14 03:32:24 -07:00
parent 0f33b04c87
commit 3f7f4852ef
30 changed files with 795 additions and 270 deletions

View file

@ -216,6 +216,48 @@ func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
}
}
// MustOwner always returns a valid *User object to avoid
// conceptually impossible error handling.
// It creates a fake object that contains error deftail
// when error occurs.
func (repo *Repository) MustOwner() *User {
return repo.mustOwner(x)
}
func (repo *Repository) FullName() string {
return repo.MustOwner().Name + "/" + repo.Name
}
func (repo *Repository) FullLink() string {
return setting.AppUrl + repo.FullName()
}
// Arguments that are allowed to be nil: permission
func (repo *Repository) APIFormat(permission *api.Permission) *api.Repository {
cloneLink := repo.CloneLink()
return &api.Repository{
ID: repo.ID,
Owner: repo.Owner.APIFormat(),
Name: repo.Name,
FullName: repo.FullName(),
Description: repo.Description,
Private: repo.IsPrivate,
Fork: repo.IsFork,
HTMLURL: repo.FullLink(),
SSHURL: cloneLink.SSH,
CloneURL: cloneLink.HTTPS,
Website: repo.Website,
Stars: repo.NumStars,
Forks: repo.NumForks,
Watchers: repo.NumWatches,
OpenIssues: repo.NumOpenIssues,
DefaultBranch: repo.DefaultBranch,
Created: repo.Created,
Updated: repo.Updated,
Permissions: permission,
}
}
func (repo *Repository) getOwner(e Engine) (err error) {
if repo.Owner != nil {
return nil
@ -240,14 +282,6 @@ func (repo *Repository) mustOwner(e Engine) *User {
return repo.Owner
}
// MustOwner always returns a valid *User object to avoid
// conceptually impossible error handling.
// It creates a fake object that contains error deftail
// when error occurs.
func (repo *Repository) MustOwner() *User {
return repo.mustOwner(x)
}
// ComposeMetas composes a map of metas for rendering external issue tracker URL.
func (repo *Repository) ComposeMetas() map[string]string {
if !repo.EnableExternalTracker {
@ -357,10 +391,6 @@ func (repo *Repository) ComposeCompareURL(oldCommitID, newCommitID string) strin
return fmt.Sprintf("%s/%s/compare/%s...%s", repo.MustOwner().Name, repo.Name, oldCommitID, newCommitID)
}
func (repo *Repository) FullLink() string {
return setting.AppUrl + repo.MustOwner().Name + "/" + repo.Name
}
func (repo *Repository) HasAccess(u *User) bool {
has, _ := HasAccess(u, repo, ACCESS_MODE_READ)
return has