forked from gitea/gitea
Merge branch 'master' into refactor_issues-subscription
This commit is contained in:
commit
717237a91e
|
@ -73,6 +73,9 @@ issues:
|
||||||
- path: routers/routes/routes.go
|
- path: routers/routes/routes.go
|
||||||
linters:
|
linters:
|
||||||
- dupl
|
- dupl
|
||||||
|
- path: routers/api/v1/repo/issue_subscription.go
|
||||||
|
linters:
|
||||||
|
- dupl
|
||||||
- path: routers/repo/view.go
|
- path: routers/repo/view.go
|
||||||
linters:
|
linters:
|
||||||
- dupl
|
- dupl
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -521,4 +521,4 @@ golangci-lint:
|
||||||
export BINARY="golangci-lint"; \
|
export BINARY="golangci-lint"; \
|
||||||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.20.0; \
|
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin v1.20.0; \
|
||||||
fi
|
fi
|
||||||
golangci-lint run
|
golangci-lint run --timeout 5m
|
||||||
|
|
|
@ -173,6 +173,20 @@ menu:
|
||||||
- `MAX_SIZE`: 附件最大限制,单位 MB,比如: `4`。
|
- `MAX_SIZE`: 附件最大限制,单位 MB,比如: `4`。
|
||||||
- `MAX_FILES`: 一次最多上传的附件数量,比如: `5`。
|
- `MAX_FILES`: 一次最多上传的附件数量,比如: `5`。
|
||||||
|
|
||||||
|
关于 `ALLOWED_TYPES`, 在 (*)unix 系统中可以使用`file -I <filename>` 来快速获得对应的 `MIME type`。
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ file -I test00.tar.xz
|
||||||
|
test00.tar.xz: application/x-xz; charset=binary
|
||||||
|
|
||||||
|
$ file --mime test00.xlsx
|
||||||
|
test00.xlsx: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=binary
|
||||||
|
|
||||||
|
file -I test01.xls
|
||||||
|
test01.xls: application/vnd.ms-excel; charset=binary
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Log (`log`)
|
## Log (`log`)
|
||||||
|
|
||||||
- `ROOT_PATH`: 日志文件根目录。
|
- `ROOT_PATH`: 日志文件根目录。
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -69,6 +69,8 @@ require (
|
||||||
github.com/mattn/go-sqlite3 v1.11.0
|
github.com/mattn/go-sqlite3 v1.11.0
|
||||||
github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75
|
github.com/mcuadros/go-version v0.0.0-20190308113854-92cdf37c5b75
|
||||||
github.com/microcosm-cc/bluemonday v0.0.0-20161012083705-f77f16ffc87a
|
github.com/microcosm-cc/bluemonday v0.0.0-20161012083705-f77f16ffc87a
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
|
github.com/modern-go/reflect2 v1.0.1 // indirect
|
||||||
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae // indirect
|
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae // indirect
|
||||||
github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc
|
github.com/msteinert/pam v0.0.0-20151204160544-02ccfbfaf0cc
|
||||||
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
|
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5
|
||||||
|
|
|
@ -647,6 +647,23 @@ func (err ErrLFSLockAlreadyExist) Error() string {
|
||||||
return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path)
|
return fmt.Sprintf("lfs lock already exists [rid: %d, path: %s]", err.RepoID, err.Path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ErrLFSFileLocked represents a "LFSFileLocked" kind of error.
|
||||||
|
type ErrLFSFileLocked struct {
|
||||||
|
RepoID int64
|
||||||
|
Path string
|
||||||
|
UserName string
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsErrLFSFileLocked checks if an error is a ErrLFSFileLocked.
|
||||||
|
func IsErrLFSFileLocked(err error) bool {
|
||||||
|
_, ok := err.(ErrLFSFileLocked)
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err ErrLFSFileLocked) Error() string {
|
||||||
|
return fmt.Sprintf("File is lfs locked [repo: %d, locked by: %s, path: %s]", err.RepoID, err.UserName, err.Path)
|
||||||
|
}
|
||||||
|
|
||||||
// __________ .__ __
|
// __________ .__ __
|
||||||
// \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
|
// \______ \ ____ ______ ____ _____|__|/ |_ ___________ ___.__.
|
||||||
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
|
// | _// __ \\____ \ / _ \/ ___/ \ __\/ _ \_ __ < | |
|
||||||
|
|
|
@ -16,6 +16,9 @@ type IssueWatch struct {
|
||||||
UpdatedUnix timeutil.TimeStamp `xorm:"updated NOT NULL"`
|
UpdatedUnix timeutil.TimeStamp `xorm:"updated NOT NULL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IssueWatchList contains IssueWatch
|
||||||
|
type IssueWatchList []*IssueWatch
|
||||||
|
|
||||||
// CreateOrUpdateIssueWatch set watching for a user and issue
|
// CreateOrUpdateIssueWatch set watching for a user and issue
|
||||||
func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error {
|
func CreateOrUpdateIssueWatch(userID, issueID int64, isWatching bool) error {
|
||||||
iw, exists, err := getIssueWatch(x, userID, issueID)
|
iw, exists, err := getIssueWatch(x, userID, issueID)
|
||||||
|
@ -59,12 +62,11 @@ func getIssueWatch(e Engine, userID, issueID int64) (iw *IssueWatch, exists bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetIssueWatchers returns watchers/unwatchers of a given issue
|
// GetIssueWatchers returns watchers/unwatchers of a given issue
|
||||||
func GetIssueWatchers(issueID int64) ([]*IssueWatch, error) {
|
func GetIssueWatchers(issueID int64) (IssueWatchList, error) {
|
||||||
return getIssueWatchers(x, issueID)
|
return getIssueWatchers(x, issueID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIssueWatchers(e Engine, issueID int64) (watches []*IssueWatch, err error) {
|
func getIssueWatchers(e Engine, issueID int64) (watches IssueWatchList, err error) {
|
||||||
// handle manual watchers
|
|
||||||
err = e.
|
err = e.
|
||||||
Where("`issue_watch`.issue_id = ?", issueID).
|
Where("`issue_watch`.issue_id = ?", issueID).
|
||||||
And("`issue_watch`.is_watching = ?", true).
|
And("`issue_watch`.is_watching = ?", true).
|
||||||
|
@ -91,3 +93,29 @@ func removeIssueWatchersByRepoID(e Engine, userID int64, repoID int64) error {
|
||||||
Update(iw)
|
Update(iw)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LoadWatchUsers return watching users
|
||||||
|
func (iwl IssueWatchList) LoadWatchUsers() (users UserList, err error) {
|
||||||
|
return iwl.loadWatchUsers(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (iwl IssueWatchList) loadWatchUsers(e Engine) (users UserList, err error) {
|
||||||
|
if len(iwl) == 0 {
|
||||||
|
return []*User{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var userIDs = make([]int64, 0, len(iwl))
|
||||||
|
for _, iw := range iwl {
|
||||||
|
if iw.IsWatching {
|
||||||
|
userIDs = append(userIDs, iw.UserID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(userIDs) == 0 {
|
||||||
|
return []*User{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err = e.In("id", userIDs).Find(&users)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
)
|
)
|
||||||
|
|
||||||
//UserList is a list of user.
|
//UserList is a list of user.
|
||||||
|
@ -93,3 +94,12 @@ func (users UserList) loadTwoFactorStatus(e Engine) (map[int64]*TwoFactor, error
|
||||||
}
|
}
|
||||||
return tokenMaps, nil
|
return tokenMaps, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//APIFormat return list of users in api format
|
||||||
|
func (users UserList) APIFormat() []*api.User {
|
||||||
|
var result []*api.User
|
||||||
|
for _, u := range users {
|
||||||
|
result = append(result, u.APIFormat())
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
|
@ -6,34 +6,18 @@
|
||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/hmac"
|
|
||||||
"crypto/sha256"
|
|
||||||
"crypto/tls"
|
|
||||||
"encoding/hex"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/git"
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/sync"
|
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
|
||||||
"github.com/gobwas/glob"
|
|
||||||
gouuid "github.com/satori/go.uuid"
|
gouuid "github.com/satori/go.uuid"
|
||||||
"github.com/unknwon/com"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// HookQueue is a global queue of web hooks
|
|
||||||
var HookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
|
|
||||||
|
|
||||||
// HookContentType is the content type of a web hook
|
// HookContentType is the content type of a web hook
|
||||||
type HookContentType int
|
type HookContentType int
|
||||||
|
|
||||||
|
@ -227,13 +211,14 @@ func (w *Webhook) HasRepositoryEvent() bool {
|
||||||
(w.ChooseEvents && w.HookEvents.Repository)
|
(w.ChooseEvents && w.HookEvents.Repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Webhook) eventCheckers() []struct {
|
// EventCheckers returns event checkers
|
||||||
has func() bool
|
func (w *Webhook) EventCheckers() []struct {
|
||||||
typ HookEventType
|
Has func() bool
|
||||||
|
Type HookEventType
|
||||||
} {
|
} {
|
||||||
return []struct {
|
return []struct {
|
||||||
has func() bool
|
Has func() bool
|
||||||
typ HookEventType
|
Type HookEventType
|
||||||
}{
|
}{
|
||||||
{w.HasCreateEvent, HookEventCreate},
|
{w.HasCreateEvent, HookEventCreate},
|
||||||
{w.HasDeleteEvent, HookEventDelete},
|
{w.HasDeleteEvent, HookEventDelete},
|
||||||
|
@ -251,29 +236,14 @@ func (w *Webhook) eventCheckers() []struct {
|
||||||
func (w *Webhook) EventsArray() []string {
|
func (w *Webhook) EventsArray() []string {
|
||||||
events := make([]string, 0, 7)
|
events := make([]string, 0, 7)
|
||||||
|
|
||||||
for _, c := range w.eventCheckers() {
|
for _, c := range w.EventCheckers() {
|
||||||
if c.has() {
|
if c.Has() {
|
||||||
events = append(events, string(c.typ))
|
events = append(events, string(c.Type))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Webhook) checkBranch(branch string) bool {
|
|
||||||
if w.BranchFilter == "" || w.BranchFilter == "*" {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
g, err := glob.Compile(w.BranchFilter)
|
|
||||||
if err != nil {
|
|
||||||
// should not really happen as BranchFilter is validated
|
|
||||||
log.Error("CheckBranch failed: %s", err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return g.Match(branch)
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateWebhook creates a new web hook.
|
// CreateWebhook creates a new web hook.
|
||||||
func CreateWebhook(w *Webhook) error {
|
func CreateWebhook(w *Webhook) error {
|
||||||
return createWebhook(x, w)
|
return createWebhook(x, w)
|
||||||
|
@ -664,329 +634,20 @@ func UpdateHookTask(t *HookTask) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// PrepareWebhook adds special webhook to task queue for given payload.
|
// FindUndeliveredHookTasks represents find the undelivered hook tasks
|
||||||
func PrepareWebhook(w *Webhook, repo *Repository, event HookEventType, p api.Payloader) error {
|
func FindUndeliveredHookTasks() ([]*HookTask, error) {
|
||||||
return prepareWebhook(x, w, repo, event, p)
|
|
||||||
}
|
|
||||||
|
|
||||||
// getPayloadBranch returns branch for hook event, if applicable.
|
|
||||||
func getPayloadBranch(p api.Payloader) string {
|
|
||||||
switch pp := p.(type) {
|
|
||||||
case *api.CreatePayload:
|
|
||||||
if pp.RefType == "branch" {
|
|
||||||
return pp.Ref
|
|
||||||
}
|
|
||||||
case *api.DeletePayload:
|
|
||||||
if pp.RefType == "branch" {
|
|
||||||
return pp.Ref
|
|
||||||
}
|
|
||||||
case *api.PushPayload:
|
|
||||||
if strings.HasPrefix(pp.Ref, git.BranchPrefix) {
|
|
||||||
return pp.Ref[len(git.BranchPrefix):]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareWebhook(e Engine, w *Webhook, repo *Repository, event HookEventType, p api.Payloader) error {
|
|
||||||
for _, e := range w.eventCheckers() {
|
|
||||||
if event == e.typ {
|
|
||||||
if !e.has() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If payload has no associated branch (e.g. it's a new tag, issue, etc.),
|
|
||||||
// branch filter has no effect.
|
|
||||||
if branch := getPayloadBranch(p); branch != "" {
|
|
||||||
if !w.checkBranch(branch) {
|
|
||||||
log.Info("Branch %q doesn't match branch filter %q, skipping", branch, w.BranchFilter)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var payloader api.Payloader
|
|
||||||
var err error
|
|
||||||
// Use separate objects so modifications won't be made on payload on non-Gogs/Gitea type hooks.
|
|
||||||
switch w.HookTaskType {
|
|
||||||
case SLACK:
|
|
||||||
payloader, err = GetSlackPayload(p, event, w.Meta)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("GetSlackPayload: %v", err)
|
|
||||||
}
|
|
||||||
case DISCORD:
|
|
||||||
payloader, err = GetDiscordPayload(p, event, w.Meta)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("GetDiscordPayload: %v", err)
|
|
||||||
}
|
|
||||||
case DINGTALK:
|
|
||||||
payloader, err = GetDingtalkPayload(p, event, w.Meta)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("GetDingtalkPayload: %v", err)
|
|
||||||
}
|
|
||||||
case TELEGRAM:
|
|
||||||
payloader, err = GetTelegramPayload(p, event, w.Meta)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("GetTelegramPayload: %v", err)
|
|
||||||
}
|
|
||||||
case MSTEAMS:
|
|
||||||
payloader, err = GetMSTeamsPayload(p, event, w.Meta)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("GetMSTeamsPayload: %v", err)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
p.SetSecret(w.Secret)
|
|
||||||
payloader = p
|
|
||||||
}
|
|
||||||
|
|
||||||
var signature string
|
|
||||||
if len(w.Secret) > 0 {
|
|
||||||
data, err := payloader.JSONPayload()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("prepareWebhooks.JSONPayload: %v", err)
|
|
||||||
}
|
|
||||||
sig := hmac.New(sha256.New, []byte(w.Secret))
|
|
||||||
_, err = sig.Write(data)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("prepareWebhooks.sigWrite: %v", err)
|
|
||||||
}
|
|
||||||
signature = hex.EncodeToString(sig.Sum(nil))
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = createHookTask(e, &HookTask{
|
|
||||||
RepoID: repo.ID,
|
|
||||||
HookID: w.ID,
|
|
||||||
Type: w.HookTaskType,
|
|
||||||
URL: w.URL,
|
|
||||||
Signature: signature,
|
|
||||||
Payloader: payloader,
|
|
||||||
HTTPMethod: w.HTTPMethod,
|
|
||||||
ContentType: w.ContentType,
|
|
||||||
EventType: event,
|
|
||||||
IsSSL: w.IsSSL,
|
|
||||||
}); err != nil {
|
|
||||||
return fmt.Errorf("CreateHookTask: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// PrepareWebhooks adds new webhooks to task queue for given payload.
|
|
||||||
func PrepareWebhooks(repo *Repository, event HookEventType, p api.Payloader) error {
|
|
||||||
return prepareWebhooks(x, repo, event, p)
|
|
||||||
}
|
|
||||||
|
|
||||||
func prepareWebhooks(e Engine, repo *Repository, event HookEventType, p api.Payloader) error {
|
|
||||||
ws, err := getActiveWebhooksByRepoID(e, repo.ID)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("GetActiveWebhooksByRepoID: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if repo belongs to org and append additional webhooks
|
|
||||||
if repo.mustOwner(e).IsOrganization() {
|
|
||||||
// get hooks for org
|
|
||||||
orgHooks, err := getActiveWebhooksByOrgID(e, repo.OwnerID)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("GetActiveWebhooksByOrgID: %v", err)
|
|
||||||
}
|
|
||||||
ws = append(ws, orgHooks...)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(ws) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, w := range ws {
|
|
||||||
if err = prepareWebhook(e, w, repo, event, p); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (t *HookTask) deliver() error {
|
|
||||||
t.IsDelivered = true
|
|
||||||
|
|
||||||
var req *http.Request
|
|
||||||
var err error
|
|
||||||
|
|
||||||
switch t.HTTPMethod {
|
|
||||||
case "":
|
|
||||||
log.Info("HTTP Method for webhook %d empty, setting to POST as default", t.ID)
|
|
||||||
fallthrough
|
|
||||||
case http.MethodPost:
|
|
||||||
switch t.ContentType {
|
|
||||||
case ContentTypeJSON:
|
|
||||||
req, err = http.NewRequest("POST", t.URL, strings.NewReader(t.PayloadContent))
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/json")
|
|
||||||
case ContentTypeForm:
|
|
||||||
var forms = url.Values{
|
|
||||||
"payload": []string{t.PayloadContent},
|
|
||||||
}
|
|
||||||
|
|
||||||
req, err = http.NewRequest("POST", t.URL, strings.NewReader(forms.Encode()))
|
|
||||||
if err != nil {
|
|
||||||
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
|
||||||
}
|
|
||||||
case http.MethodGet:
|
|
||||||
u, err := url.Parse(t.URL)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
vals := u.Query()
|
|
||||||
vals["payload"] = []string{t.PayloadContent}
|
|
||||||
u.RawQuery = vals.Encode()
|
|
||||||
req, err = http.NewRequest("GET", u.String(), nil)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("Invalid http method for webhook: [%d] %v", t.ID, t.HTTPMethod)
|
|
||||||
}
|
|
||||||
|
|
||||||
req.Header.Add("X-Gitea-Delivery", t.UUID)
|
|
||||||
req.Header.Add("X-Gitea-Event", string(t.EventType))
|
|
||||||
req.Header.Add("X-Gitea-Signature", t.Signature)
|
|
||||||
req.Header.Add("X-Gogs-Delivery", t.UUID)
|
|
||||||
req.Header.Add("X-Gogs-Event", string(t.EventType))
|
|
||||||
req.Header.Add("X-Gogs-Signature", t.Signature)
|
|
||||||
req.Header["X-GitHub-Delivery"] = []string{t.UUID}
|
|
||||||
req.Header["X-GitHub-Event"] = []string{string(t.EventType)}
|
|
||||||
|
|
||||||
// Record delivery information.
|
|
||||||
t.RequestInfo = &HookRequest{
|
|
||||||
Headers: map[string]string{},
|
|
||||||
}
|
|
||||||
for k, vals := range req.Header {
|
|
||||||
t.RequestInfo.Headers[k] = strings.Join(vals, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
t.ResponseInfo = &HookResponse{
|
|
||||||
Headers: map[string]string{},
|
|
||||||
}
|
|
||||||
|
|
||||||
defer func() {
|
|
||||||
t.Delivered = time.Now().UnixNano()
|
|
||||||
if t.IsSucceed {
|
|
||||||
log.Trace("Hook delivered: %s", t.UUID)
|
|
||||||
} else {
|
|
||||||
log.Trace("Hook delivery failed: %s", t.UUID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := UpdateHookTask(t); err != nil {
|
|
||||||
log.Error("UpdateHookTask [%d]: %v", t.ID, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update webhook last delivery status.
|
|
||||||
w, err := GetWebhookByID(t.HookID)
|
|
||||||
if err != nil {
|
|
||||||
log.Error("GetWebhookByID: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if t.IsSucceed {
|
|
||||||
w.LastStatus = HookStatusSucceed
|
|
||||||
} else {
|
|
||||||
w.LastStatus = HookStatusFail
|
|
||||||
}
|
|
||||||
if err = UpdateWebhookLastStatus(w); err != nil {
|
|
||||||
log.Error("UpdateWebhookLastStatus: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
resp, err := webhookHTTPClient.Do(req)
|
|
||||||
if err != nil {
|
|
||||||
t.ResponseInfo.Body = fmt.Sprintf("Delivery: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
// Status code is 20x can be seen as succeed.
|
|
||||||
t.IsSucceed = resp.StatusCode/100 == 2
|
|
||||||
t.ResponseInfo.Status = resp.StatusCode
|
|
||||||
for k, vals := range resp.Header {
|
|
||||||
t.ResponseInfo.Headers[k] = strings.Join(vals, ",")
|
|
||||||
}
|
|
||||||
|
|
||||||
p, err := ioutil.ReadAll(resp.Body)
|
|
||||||
if err != nil {
|
|
||||||
t.ResponseInfo.Body = fmt.Sprintf("read body: %s", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
t.ResponseInfo.Body = string(p)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeliverHooks checks and delivers undelivered hooks.
|
|
||||||
// TODO: shoot more hooks at same time.
|
|
||||||
func DeliverHooks() {
|
|
||||||
tasks := make([]*HookTask, 0, 10)
|
tasks := make([]*HookTask, 0, 10)
|
||||||
err := x.Where("is_delivered=?", false).Find(&tasks)
|
if err := x.Where("is_delivered=?", false).Find(&tasks); err != nil {
|
||||||
if err != nil {
|
|
||||||
log.Error("DeliverHooks: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update hook task status.
|
|
||||||
for _, t := range tasks {
|
|
||||||
if err = t.deliver(); err != nil {
|
|
||||||
log.Error("deliver: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start listening on new hook requests.
|
|
||||||
for repoIDStr := range HookQueue.Queue() {
|
|
||||||
log.Trace("DeliverHooks [repo_id: %v]", repoIDStr)
|
|
||||||
HookQueue.Remove(repoIDStr)
|
|
||||||
|
|
||||||
repoID, err := com.StrTo(repoIDStr).Int64()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("Invalid repo ID: %s", repoIDStr)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks = make([]*HookTask, 0, 5)
|
|
||||||
if err := x.Where("repo_id=? AND is_delivered=?", repoID, false).Find(&tasks); err != nil {
|
|
||||||
log.Error("Get repository [%d] hook tasks: %v", repoID, err)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
for _, t := range tasks {
|
|
||||||
if err = t.deliver(); err != nil {
|
|
||||||
log.Error("deliver: %v", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var webhookHTTPClient *http.Client
|
|
||||||
|
|
||||||
// InitDeliverHooks starts the hooks delivery thread
|
|
||||||
func InitDeliverHooks() {
|
|
||||||
timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second
|
|
||||||
|
|
||||||
webhookHTTPClient = &http.Client{
|
|
||||||
Transport: &http.Transport{
|
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify},
|
|
||||||
Proxy: http.ProxyFromEnvironment,
|
|
||||||
Dial: func(netw, addr string) (net.Conn, error) {
|
|
||||||
conn, err := net.DialTimeout(netw, addr, timeout)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return tasks, nil
|
||||||
return conn, conn.SetDeadline(time.Now().Add(timeout))
|
|
||||||
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go DeliverHooks()
|
// FindRepoUndeliveredHookTasks represents find the undelivered hook tasks of one repository
|
||||||
|
func FindRepoUndeliveredHookTasks(repoID int64) ([]*HookTask, error) {
|
||||||
|
tasks := make([]*HookTask, 0, 5)
|
||||||
|
if err := x.Where("repo_id=? AND is_delivered=?", repoID, false).Find(&tasks); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return tasks, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,57 +253,3 @@ func TestUpdateHookTask(t *testing.T) {
|
||||||
assert.NoError(t, UpdateHookTask(hook))
|
assert.NoError(t, UpdateHookTask(hook))
|
||||||
AssertExistsAndLoadBean(t, hook)
|
AssertExistsAndLoadBean(t, hook)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrepareWebhooks(t *testing.T) {
|
|
||||||
assert.NoError(t, PrepareTestDatabase())
|
|
||||||
|
|
||||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository)
|
|
||||||
hookTasks := []*HookTask{
|
|
||||||
{RepoID: repo.ID, HookID: 1, EventType: HookEventPush},
|
|
||||||
}
|
|
||||||
for _, hookTask := range hookTasks {
|
|
||||||
AssertNotExistsBean(t, hookTask)
|
|
||||||
}
|
|
||||||
assert.NoError(t, PrepareWebhooks(repo, HookEventPush, &api.PushPayload{}))
|
|
||||||
for _, hookTask := range hookTasks {
|
|
||||||
AssertExistsAndLoadBean(t, hookTask)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
|
|
||||||
assert.NoError(t, PrepareTestDatabase())
|
|
||||||
|
|
||||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
|
|
||||||
hookTasks := []*HookTask{
|
|
||||||
{RepoID: repo.ID, HookID: 4, EventType: HookEventPush},
|
|
||||||
}
|
|
||||||
for _, hookTask := range hookTasks {
|
|
||||||
AssertNotExistsBean(t, hookTask)
|
|
||||||
}
|
|
||||||
// this test also ensures that * doesn't handle / in any special way (like shell would)
|
|
||||||
assert.NoError(t, PrepareWebhooks(repo, HookEventPush, &api.PushPayload{Ref: "refs/heads/feature/7791"}))
|
|
||||||
for _, hookTask := range hookTasks {
|
|
||||||
AssertExistsAndLoadBean(t, hookTask)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
|
|
||||||
assert.NoError(t, PrepareTestDatabase())
|
|
||||||
|
|
||||||
repo := AssertExistsAndLoadBean(t, &Repository{ID: 2}).(*Repository)
|
|
||||||
hookTasks := []*HookTask{
|
|
||||||
{RepoID: repo.ID, HookID: 4, EventType: HookEventPush},
|
|
||||||
}
|
|
||||||
for _, hookTask := range hookTasks {
|
|
||||||
AssertNotExistsBean(t, hookTask)
|
|
||||||
}
|
|
||||||
assert.NoError(t, PrepareWebhooks(repo, HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"}))
|
|
||||||
|
|
||||||
for _, hookTask := range hookTasks {
|
|
||||||
AssertNotExistsBean(t, hookTask)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO TestHookTask_deliver
|
|
||||||
|
|
||||||
// TODO TestDeliverHooks
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ package git
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -133,6 +134,13 @@ func Init() error {
|
||||||
return fmt.Errorf("Failed to execute 'git config --global gc.writeCommitGraph true': %s", stderr)
|
return fmt.Errorf("Failed to execute 'git config --global gc.writeCommitGraph true': %s", stderr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if runtime.GOOS == "windows" {
|
||||||
|
if _, stderr, err := process.GetManager().Exec("git.Init(git config --global core.longpaths true)",
|
||||||
|
GitExecutable, "config", "--global", "core.longpaths", "true"); err != nil {
|
||||||
|
return fmt.Errorf("Failed to execute 'git config --global core.longpaths true': %s", stderr)
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,11 @@ func (h *Hook) Update() error {
|
||||||
h.IsActive = false
|
h.IsActive = false
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
d := filepath.Dir(h.path)
|
||||||
|
if err := os.MkdirAll(d, os.ModePerm); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
|
err := ioutil.WriteFile(h.path, []byte(strings.Replace(h.Content, "\r", "", -1)), os.ModePerm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -20,7 +20,7 @@ type Notifier interface {
|
||||||
|
|
||||||
NotifyNewIssue(*models.Issue)
|
NotifyNewIssue(*models.Issue)
|
||||||
NotifyIssueChangeStatus(*models.User, *models.Issue, bool)
|
NotifyIssueChangeStatus(*models.User, *models.Issue, bool)
|
||||||
NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue)
|
NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue, oldMilestoneID int64)
|
||||||
NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment)
|
NotifyIssueChangeAssignee(doer *models.User, issue *models.Issue, assignee *models.User, removed bool, comment *models.Comment)
|
||||||
NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string)
|
NotifyIssueChangeContent(doer *models.User, issue *models.Issue, oldContent string)
|
||||||
NotifyIssueClearLabels(doer *models.User, issue *models.Issue)
|
NotifyIssueClearLabels(doer *models.User, issue *models.Issue)
|
||||||
|
|
|
@ -75,7 +75,7 @@ func (*NullNotifier) NotifyDeleteRelease(doer *models.User, rel *models.Release)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyIssueChangeMilestone places a place holder function
|
// NotifyIssueChangeMilestone places a place holder function
|
||||||
func (*NullNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue) {
|
func (*NullNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue, oldMilestoneID int64) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyIssueChangeContent places a place holder function
|
// NotifyIssueChangeContent places a place holder function
|
||||||
|
|
|
@ -128,9 +128,9 @@ func NotifyDeleteRelease(doer *models.User, rel *models.Release) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotifyIssueChangeMilestone notifies change milestone to notifiers
|
// NotifyIssueChangeMilestone notifies change milestone to notifiers
|
||||||
func NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue) {
|
func NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue, oldMilestoneID int64) {
|
||||||
for _, notifier := range notifiers {
|
for _, notifier := range notifiers {
|
||||||
notifier.NotifyIssueChangeMilestone(doer, issue)
|
notifier.NotifyIssueChangeMilestone(doer, issue, oldMilestoneID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/notification/base"
|
"code.gitea.io/gitea/modules/notification/base"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
webhook_module "code.gitea.io/gitea/modules/webhook"
|
||||||
)
|
)
|
||||||
|
|
||||||
type webhookNotifier struct {
|
type webhookNotifier struct {
|
||||||
|
@ -43,7 +44,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueLabelCleared,
|
Action: api.HookIssueLabelCleared,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
PullRequest: issue.PullRequest.APIFormat(),
|
PullRequest: issue.PullRequest.APIFormat(),
|
||||||
|
@ -51,7 +52,7 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
||||||
Action: api.HookIssueLabelCleared,
|
Action: api.HookIssueLabelCleared,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: issue.APIFormat(),
|
Issue: issue.APIFormat(),
|
||||||
|
@ -61,8 +62,6 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,29 +70,25 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
|
||||||
mode, _ := models.AccessLevel(doer, repo)
|
mode, _ := models.AccessLevel(doer, repo)
|
||||||
|
|
||||||
// forked webhook
|
// forked webhook
|
||||||
if err := models.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{
|
if err := webhook_module.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{
|
||||||
Forkee: oldRepo.APIFormat(oldMode),
|
Forkee: oldRepo.APIFormat(oldMode),
|
||||||
Repo: repo.APIFormat(mode),
|
Repo: repo.APIFormat(mode),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err)
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", oldRepo.ID, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(oldRepo.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u := repo.MustOwner()
|
u := repo.MustOwner()
|
||||||
|
|
||||||
// Add to hook queue for created repo after session commit.
|
// Add to hook queue for created repo after session commit.
|
||||||
if u.IsOrganization() {
|
if u.IsOrganization() {
|
||||||
if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
||||||
Action: api.HookRepoCreated,
|
Action: api.HookRepoCreated,
|
||||||
Repository: repo.APIFormat(models.AccessModeOwner),
|
Repository: repo.APIFormat(models.AccessModeOwner),
|
||||||
Organization: u.APIFormat(),
|
Organization: u.APIFormat(),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,15 +96,13 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
|
||||||
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
|
||||||
// Add to hook queue for created repo after session commit.
|
// Add to hook queue for created repo after session commit.
|
||||||
if u.IsOrganization() {
|
if u.IsOrganization() {
|
||||||
if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
||||||
Action: api.HookRepoCreated,
|
Action: api.HookRepoCreated,
|
||||||
Repository: repo.APIFormat(models.AccessModeOwner),
|
Repository: repo.APIFormat(models.AccessModeOwner),
|
||||||
Organization: u.APIFormat(),
|
Organization: u.APIFormat(),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +111,7 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models
|
||||||
u := repo.MustOwner()
|
u := repo.MustOwner()
|
||||||
|
|
||||||
if u.IsOrganization() {
|
if u.IsOrganization() {
|
||||||
if err := models.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
|
||||||
Action: api.HookRepoDeleted,
|
Action: api.HookRepoDeleted,
|
||||||
Repository: repo.APIFormat(models.AccessModeOwner),
|
Repository: repo.APIFormat(models.AccessModeOwner),
|
||||||
Organization: u.APIFormat(),
|
Organization: u.APIFormat(),
|
||||||
|
@ -126,7 +119,6 @@ func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
log.Error("PrepareWebhooks [repo_id: %d]: %v", repo.ID, err)
|
||||||
}
|
}
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +143,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
|
||||||
apiPullRequest.Action = api.HookIssueAssigned
|
apiPullRequest.Action = api.HookIssueAssigned
|
||||||
}
|
}
|
||||||
// Assignee comment triggers a webhook
|
// Assignee comment triggers a webhook
|
||||||
if err := models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest); err != nil {
|
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest); err != nil {
|
||||||
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
|
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -169,13 +161,11 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
|
||||||
apiIssue.Action = api.HookIssueAssigned
|
apiIssue.Action = api.HookIssueAssigned
|
||||||
}
|
}
|
||||||
// Assignee comment triggers a webhook
|
// Assignee comment triggers a webhook
|
||||||
if err := models.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue); err != nil {
|
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue); err != nil {
|
||||||
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
|
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) {
|
func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *models.Issue, oldTitle string) {
|
||||||
|
@ -187,7 +177,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
issue.PullRequest.Issue = issue
|
issue.PullRequest.Issue = issue
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueEdited,
|
Action: api.HookIssueEdited,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Changes: &api.ChangesPayload{
|
Changes: &api.ChangesPayload{
|
||||||
|
@ -200,7 +190,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
||||||
Action: api.HookIssueEdited,
|
Action: api.HookIssueEdited,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Changes: &api.ChangesPayload{
|
Changes: &api.ChangesPayload{
|
||||||
|
@ -216,8 +206,6 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,7 +229,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
|
||||||
} else {
|
} else {
|
||||||
apiPullRequest.Action = api.HookIssueReOpened
|
apiPullRequest.Action = api.HookIssueReOpened
|
||||||
}
|
}
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest)
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest)
|
||||||
} else {
|
} else {
|
||||||
apiIssue := &api.IssuePayload{
|
apiIssue := &api.IssuePayload{
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
|
@ -254,18 +242,16 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
|
||||||
} else {
|
} else {
|
||||||
apiIssue.Action = api.HookIssueReOpened
|
apiIssue.Action = api.HookIssueReOpened
|
||||||
}
|
}
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue)
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
|
log.Error("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(issue.Repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) {
|
func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) {
|
||||||
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
|
||||||
if err := models.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
||||||
Action: api.HookIssueOpened,
|
Action: api.HookIssueOpened,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Issue: issue.APIFormat(),
|
Issue: issue.APIFormat(),
|
||||||
|
@ -273,8 +259,6 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) {
|
||||||
Sender: issue.Poster.APIFormat(),
|
Sender: issue.Poster.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks: %v", err)
|
log.Error("PrepareWebhooks: %v", err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,7 +267,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
|
||||||
var err error
|
var err error
|
||||||
if issue.IsPull {
|
if issue.IsPull {
|
||||||
issue.PullRequest.Issue = issue
|
issue.PullRequest.Issue = issue
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueEdited,
|
Action: api.HookIssueEdited,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Changes: &api.ChangesPayload{
|
Changes: &api.ChangesPayload{
|
||||||
|
@ -296,7 +280,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
||||||
Action: api.HookIssueEdited,
|
Action: api.HookIssueEdited,
|
||||||
Index: issue.Index,
|
Index: issue.Index,
|
||||||
Changes: &api.ChangesPayload{
|
Changes: &api.ChangesPayload{
|
||||||
|
@ -311,8 +295,6 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +314,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
|
||||||
}
|
}
|
||||||
|
|
||||||
mode, _ := models.AccessLevel(doer, c.Issue.Repo)
|
mode, _ := models.AccessLevel(doer, c.Issue.Repo)
|
||||||
if err := models.PrepareWebhooks(c.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
|
if err := webhook_module.PrepareWebhooks(c.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
|
||||||
Action: api.HookIssueCommentEdited,
|
Action: api.HookIssueCommentEdited,
|
||||||
Issue: c.Issue.APIFormat(),
|
Issue: c.Issue.APIFormat(),
|
||||||
Comment: c.APIFormat(),
|
Comment: c.APIFormat(),
|
||||||
|
@ -346,15 +328,13 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
|
||||||
IsPull: c.Issue.IsPull,
|
IsPull: c.Issue.IsPull,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks [comment_id: %d]: %v", c.ID, err)
|
log.Error("PrepareWebhooks [comment_id: %d]: %v", c.ID, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(c.Issue.Repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
|
func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
|
||||||
issue *models.Issue, comment *models.Comment) {
|
issue *models.Issue, comment *models.Comment) {
|
||||||
mode, _ := models.AccessLevel(doer, repo)
|
mode, _ := models.AccessLevel(doer, repo)
|
||||||
if err := models.PrepareWebhooks(repo, models.HookEventIssueComment, &api.IssueCommentPayload{
|
if err := webhook_module.PrepareWebhooks(repo, models.HookEventIssueComment, &api.IssueCommentPayload{
|
||||||
Action: api.HookIssueCommentCreated,
|
Action: api.HookIssueCommentCreated,
|
||||||
Issue: issue.APIFormat(),
|
Issue: issue.APIFormat(),
|
||||||
Comment: comment.APIFormat(),
|
Comment: comment.APIFormat(),
|
||||||
|
@ -363,8 +343,6 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode
|
||||||
IsPull: issue.IsPull,
|
IsPull: issue.IsPull,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
|
log.Error("PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +363,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
|
||||||
|
|
||||||
mode, _ := models.AccessLevel(doer, comment.Issue.Repo)
|
mode, _ := models.AccessLevel(doer, comment.Issue.Repo)
|
||||||
|
|
||||||
if err := models.PrepareWebhooks(comment.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
|
if err := webhook_module.PrepareWebhooks(comment.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
|
||||||
Action: api.HookIssueCommentDeleted,
|
Action: api.HookIssueCommentDeleted,
|
||||||
Issue: comment.Issue.APIFormat(),
|
Issue: comment.Issue.APIFormat(),
|
||||||
Comment: comment.APIFormat(),
|
Comment: comment.APIFormat(),
|
||||||
|
@ -394,7 +372,92 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
|
||||||
IsPull: comment.Issue.IsPull,
|
IsPull: comment.Issue.IsPull,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
|
log.Error("PrepareWebhooks [comment_id: %d]: %v", comment.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *models.Issue,
|
||||||
|
addedLabels []*models.Label, removedLabels []*models.Label) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if err = issue.LoadRepo(); err != nil {
|
||||||
|
log.Error("LoadRepo: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = issue.LoadPoster(); err != nil {
|
||||||
|
log.Error("LoadPoster: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
|
||||||
|
if issue.IsPull {
|
||||||
|
if err = issue.LoadPullRequest(); err != nil {
|
||||||
|
log.Error("loadPullRequest: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err = issue.PullRequest.LoadIssue(); err != nil {
|
||||||
|
log.Error("LoadIssue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
|
Action: api.HookIssueLabelUpdated,
|
||||||
|
Index: issue.Index,
|
||||||
|
PullRequest: issue.PullRequest.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(models.AccessModeNone),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
go models.HookQueue.Add(comment.Issue.Repo.ID)
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
||||||
|
Action: api.HookIssueLabelUpdated,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(mode),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *models.Issue, oldMilestoneID int64) {
|
||||||
|
var hookAction api.HookIssueAction
|
||||||
|
var err error
|
||||||
|
if issue.MilestoneID > 0 {
|
||||||
|
hookAction = api.HookIssueMilestoned
|
||||||
|
} else {
|
||||||
|
hookAction = api.HookIssueDemilestoned
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = issue.LoadAttributes(); err != nil {
|
||||||
|
log.Error("issue.LoadAttributes failed: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mode, _ := models.AccessLevel(doer, issue.Repo)
|
||||||
|
if issue.IsPull {
|
||||||
|
err = issue.PullRequest.LoadIssue()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("LoadIssue: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
|
Action: hookAction,
|
||||||
|
Index: issue.Index,
|
||||||
|
PullRequest: issue.PullRequest.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(mode),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
||||||
|
Action: hookAction,
|
||||||
|
Index: issue.Index,
|
||||||
|
Issue: issue.APIFormat(),
|
||||||
|
Repository: issue.Repo.APIFormat(mode),
|
||||||
|
Sender: doer.APIFormat(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CommitRepoActionOptions represent options of a new commit action.
|
// CommitRepoActionOptions represent options of a new commit action.
|
||||||
|
@ -111,10 +112,6 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||||
return fmt.Errorf("NotifyWatchers: %v", err)
|
return fmt.Errorf("NotifyWatchers: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
}()
|
|
||||||
|
|
||||||
apiPusher := pusher.APIFormat()
|
apiPusher := pusher.APIFormat()
|
||||||
apiRepo := repo.APIFormat(models.AccessModeNone)
|
apiRepo := repo.APIFormat(models.AccessModeNone)
|
||||||
|
|
||||||
|
@ -134,7 +131,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("GetBranchCommitID[%s]: %v", opts.RefFullName, err)
|
log.Error("GetBranchCommitID[%s]: %v", opts.RefFullName, err)
|
||||||
}
|
}
|
||||||
if err = models.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
if err = webhook.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
Sha: shaSum,
|
Sha: shaSum,
|
||||||
RefType: "branch",
|
RefType: "branch",
|
||||||
|
@ -148,7 +145,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||||
case models.ActionDeleteBranch: // Delete Branch
|
case models.ActionDeleteBranch: // Delete Branch
|
||||||
isHookEventPush = true
|
isHookEventPush = true
|
||||||
|
|
||||||
if err = models.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
if err = webhook.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
RefType: "branch",
|
RefType: "branch",
|
||||||
PusherType: api.PusherTypeUser,
|
PusherType: api.PusherTypeUser,
|
||||||
|
@ -169,7 +166,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("GetTagCommitID[%s]: %v", opts.RefFullName, err)
|
log.Error("GetTagCommitID[%s]: %v", opts.RefFullName, err)
|
||||||
}
|
}
|
||||||
if err = models.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
if err = webhook.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
Sha: shaSum,
|
Sha: shaSum,
|
||||||
RefType: "tag",
|
RefType: "tag",
|
||||||
|
@ -181,7 +178,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||||
case models.ActionDeleteTag: // Delete Tag
|
case models.ActionDeleteTag: // Delete Tag
|
||||||
isHookEventPush = true
|
isHookEventPush = true
|
||||||
|
|
||||||
if err = models.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
if err = webhook.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
||||||
Ref: refName,
|
Ref: refName,
|
||||||
RefType: "tag",
|
RefType: "tag",
|
||||||
PusherType: api.PusherTypeUser,
|
PusherType: api.PusherTypeUser,
|
||||||
|
@ -197,7 +194,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = models.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
|
if err = webhook.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
|
||||||
Ref: opts.RefFullName,
|
Ref: opts.RefFullName,
|
||||||
Before: opts.OldCommitID,
|
Before: opts.OldCommitID,
|
||||||
After: opts.NewCommitID,
|
After: opts.NewCommitID,
|
||||||
|
|
|
@ -55,6 +55,23 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep
|
||||||
return fmt.Errorf("GetUploadsByUUIDs [uuids: %v]: %v", opts.Files, err)
|
return fmt.Errorf("GetUploadsByUUIDs [uuids: %v]: %v", opts.Files, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
names := make([]string, len(uploads))
|
||||||
|
infos := make([]uploadInfo, len(uploads))
|
||||||
|
for i, upload := range uploads {
|
||||||
|
// Check file is not lfs locked, will return nil if lock setting not enabled
|
||||||
|
filepath := path.Join(opts.TreePath, upload.Name)
|
||||||
|
lfsLock, err := repo.GetTreePathLock(filepath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if lfsLock != nil && lfsLock.OwnerID != doer.ID {
|
||||||
|
return models.ErrLFSFileLocked{RepoID: repo.ID, Path: filepath, UserName: lfsLock.Owner.Name}
|
||||||
|
}
|
||||||
|
|
||||||
|
names[i] = upload.Name
|
||||||
|
infos[i] = uploadInfo{upload: upload}
|
||||||
|
}
|
||||||
|
|
||||||
t, err := NewTemporaryUploadRepository(repo)
|
t, err := NewTemporaryUploadRepository(repo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -67,13 +84,6 @@ func UploadRepoFiles(repo *models.Repository, doer *models.User, opts *UploadRep
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
names := make([]string, len(uploads))
|
|
||||||
infos := make([]uploadInfo, len(uploads))
|
|
||||||
for i, upload := range uploads {
|
|
||||||
names[i] = upload.Name
|
|
||||||
infos[i] = uploadInfo{upload: upload}
|
|
||||||
}
|
|
||||||
|
|
||||||
var filename2attribute2info map[string]map[string]string
|
var filename2attribute2info map[string]map[string]string
|
||||||
if setting.LFS.StartServer {
|
if setting.LFS.StartServer {
|
||||||
filename2attribute2info, err = t.CheckAttribute("filter", names...)
|
filename2attribute2info, err = t.CheckAttribute("filter", names...)
|
||||||
|
|
|
@ -246,6 +246,18 @@ func NewFuncMap() []template.FuncMap {
|
||||||
"MirrorFullAddress": mirror_service.AddressNoCredentials,
|
"MirrorFullAddress": mirror_service.AddressNoCredentials,
|
||||||
"MirrorUserName": mirror_service.Username,
|
"MirrorUserName": mirror_service.Username,
|
||||||
"MirrorPassword": mirror_service.Password,
|
"MirrorPassword": mirror_service.Password,
|
||||||
|
"CommitType": func(commit interface{}) string {
|
||||||
|
switch commit.(type) {
|
||||||
|
case models.SignCommitWithStatuses:
|
||||||
|
return "SignCommitWithStatuses"
|
||||||
|
case models.SignCommit:
|
||||||
|
return "SignCommit"
|
||||||
|
case models.UserCommit:
|
||||||
|
return "UserCommit"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
},
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,208 @@
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/models"
|
||||||
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
"github.com/unknwon/com"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Deliver deliver hook task
|
||||||
|
func Deliver(t *models.HookTask) error {
|
||||||
|
t.IsDelivered = true
|
||||||
|
|
||||||
|
var req *http.Request
|
||||||
|
var err error
|
||||||
|
|
||||||
|
switch t.HTTPMethod {
|
||||||
|
case "":
|
||||||
|
log.Info("HTTP Method for webhook %d empty, setting to POST as default", t.ID)
|
||||||
|
fallthrough
|
||||||
|
case http.MethodPost:
|
||||||
|
switch t.ContentType {
|
||||||
|
case models.ContentTypeJSON:
|
||||||
|
req, err = http.NewRequest("POST", t.URL, strings.NewReader(t.PayloadContent))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
case models.ContentTypeForm:
|
||||||
|
var forms = url.Values{
|
||||||
|
"payload": []string{t.PayloadContent},
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err = http.NewRequest("POST", t.URL, strings.NewReader(forms.Encode()))
|
||||||
|
if err != nil {
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
}
|
||||||
|
case http.MethodGet:
|
||||||
|
u, err := url.Parse(t.URL)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
vals := u.Query()
|
||||||
|
vals["payload"] = []string{t.PayloadContent}
|
||||||
|
u.RawQuery = vals.Encode()
|
||||||
|
req, err = http.NewRequest("GET", u.String(), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("Invalid http method for webhook: [%d] %v", t.ID, t.HTTPMethod)
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Add("X-Gitea-Delivery", t.UUID)
|
||||||
|
req.Header.Add("X-Gitea-Event", string(t.EventType))
|
||||||
|
req.Header.Add("X-Gitea-Signature", t.Signature)
|
||||||
|
req.Header.Add("X-Gogs-Delivery", t.UUID)
|
||||||
|
req.Header.Add("X-Gogs-Event", string(t.EventType))
|
||||||
|
req.Header.Add("X-Gogs-Signature", t.Signature)
|
||||||
|
req.Header["X-GitHub-Delivery"] = []string{t.UUID}
|
||||||
|
req.Header["X-GitHub-Event"] = []string{string(t.EventType)}
|
||||||
|
|
||||||
|
// Record delivery information.
|
||||||
|
t.RequestInfo = &models.HookRequest{
|
||||||
|
Headers: map[string]string{},
|
||||||
|
}
|
||||||
|
for k, vals := range req.Header {
|
||||||
|
t.RequestInfo.Headers[k] = strings.Join(vals, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
t.ResponseInfo = &models.HookResponse{
|
||||||
|
Headers: map[string]string{},
|
||||||
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
t.Delivered = time.Now().UnixNano()
|
||||||
|
if t.IsSucceed {
|
||||||
|
log.Trace("Hook delivered: %s", t.UUID)
|
||||||
|
} else {
|
||||||
|
log.Trace("Hook delivery failed: %s", t.UUID)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := models.UpdateHookTask(t); err != nil {
|
||||||
|
log.Error("UpdateHookTask [%d]: %v", t.ID, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update webhook last delivery status.
|
||||||
|
w, err := models.GetWebhookByID(t.HookID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("GetWebhookByID: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if t.IsSucceed {
|
||||||
|
w.LastStatus = models.HookStatusSucceed
|
||||||
|
} else {
|
||||||
|
w.LastStatus = models.HookStatusFail
|
||||||
|
}
|
||||||
|
if err = models.UpdateWebhookLastStatus(w); err != nil {
|
||||||
|
log.Error("UpdateWebhookLastStatus: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
resp, err := webhookHTTPClient.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
t.ResponseInfo.Body = fmt.Sprintf("Delivery: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
// Status code is 20x can be seen as succeed.
|
||||||
|
t.IsSucceed = resp.StatusCode/100 == 2
|
||||||
|
t.ResponseInfo.Status = resp.StatusCode
|
||||||
|
for k, vals := range resp.Header {
|
||||||
|
t.ResponseInfo.Headers[k] = strings.Join(vals, ",")
|
||||||
|
}
|
||||||
|
|
||||||
|
p, err := ioutil.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
t.ResponseInfo.Body = fmt.Sprintf("read body: %s", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
t.ResponseInfo.Body = string(p)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeliverHooks checks and delivers undelivered hooks.
|
||||||
|
// TODO: shoot more hooks at same time.
|
||||||
|
func DeliverHooks() {
|
||||||
|
tasks, err := models.FindUndeliveredHookTasks()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("DeliverHooks: %v", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update hook task status.
|
||||||
|
for _, t := range tasks {
|
||||||
|
if err = Deliver(t); err != nil {
|
||||||
|
log.Error("deliver: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start listening on new hook requests.
|
||||||
|
for repoIDStr := range hookQueue.Queue() {
|
||||||
|
log.Trace("DeliverHooks [repo_id: %v]", repoIDStr)
|
||||||
|
hookQueue.Remove(repoIDStr)
|
||||||
|
|
||||||
|
repoID, err := com.StrTo(repoIDStr).Int64()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Invalid repo ID: %s", repoIDStr)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks, err := models.FindRepoUndeliveredHookTasks(repoID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Get repository [%d] hook tasks: %v", repoID, err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for _, t := range tasks {
|
||||||
|
if err = Deliver(t); err != nil {
|
||||||
|
log.Error("deliver: %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var webhookHTTPClient *http.Client
|
||||||
|
|
||||||
|
// InitDeliverHooks starts the hooks delivery thread
|
||||||
|
func InitDeliverHooks() {
|
||||||
|
timeout := time.Duration(setting.Webhook.DeliverTimeout) * time.Second
|
||||||
|
|
||||||
|
webhookHTTPClient = &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: setting.Webhook.SkipTLSVerify},
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
Dial: func(netw, addr string) (net.Conn, error) {
|
||||||
|
conn, err := net.DialTimeout(netw, addr, timeout)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return conn, conn.SetDeadline(time.Now().Add(timeout))
|
||||||
|
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
go DeliverHooks()
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
models.MainTest(m, filepath.Join("..", ".."))
|
||||||
|
}
|
|
@ -0,0 +1,189 @@
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/hmac"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/models"
|
||||||
|
"code.gitea.io/gitea/modules/git"
|
||||||
|
"code.gitea.io/gitea/modules/log"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/sync"
|
||||||
|
"github.com/gobwas/glob"
|
||||||
|
)
|
||||||
|
|
||||||
|
// hookQueue is a global queue of web hooks
|
||||||
|
var hookQueue = sync.NewUniqueQueue(setting.Webhook.QueueLength)
|
||||||
|
|
||||||
|
// getPayloadBranch returns branch for hook event, if applicable.
|
||||||
|
func getPayloadBranch(p api.Payloader) string {
|
||||||
|
switch pp := p.(type) {
|
||||||
|
case *api.CreatePayload:
|
||||||
|
if pp.RefType == "branch" {
|
||||||
|
return pp.Ref
|
||||||
|
}
|
||||||
|
case *api.DeletePayload:
|
||||||
|
if pp.RefType == "branch" {
|
||||||
|
return pp.Ref
|
||||||
|
}
|
||||||
|
case *api.PushPayload:
|
||||||
|
if strings.HasPrefix(pp.Ref, git.BranchPrefix) {
|
||||||
|
return pp.Ref[len(git.BranchPrefix):]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrepareWebhook adds special webhook to task queue for given payload.
|
||||||
|
func PrepareWebhook(w *models.Webhook, repo *models.Repository, event models.HookEventType, p api.Payloader) error {
|
||||||
|
if err := prepareWebhook(w, repo, event, p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
go hookQueue.Add(repo.ID)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkBranch(w *models.Webhook, branch string) bool {
|
||||||
|
if w.BranchFilter == "" || w.BranchFilter == "*" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
g, err := glob.Compile(w.BranchFilter)
|
||||||
|
if err != nil {
|
||||||
|
// should not really happen as BranchFilter is validated
|
||||||
|
log.Error("CheckBranch failed: %s", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return g.Match(branch)
|
||||||
|
}
|
||||||
|
|
||||||
|
func prepareWebhook(w *models.Webhook, repo *models.Repository, event models.HookEventType, p api.Payloader) error {
|
||||||
|
for _, e := range w.EventCheckers() {
|
||||||
|
if event == e.Type {
|
||||||
|
if !e.Has() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If payload has no associated branch (e.g. it's a new tag, issue, etc.),
|
||||||
|
// branch filter has no effect.
|
||||||
|
if branch := getPayloadBranch(p); branch != "" {
|
||||||
|
if !checkBranch(w, branch) {
|
||||||
|
log.Info("Branch %q doesn't match branch filter %q, skipping", branch, w.BranchFilter)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var payloader api.Payloader
|
||||||
|
var err error
|
||||||
|
// Use separate objects so modifications won't be made on payload on non-Gogs/Gitea type hooks.
|
||||||
|
switch w.HookTaskType {
|
||||||
|
case models.SLACK:
|
||||||
|
payloader, err = models.GetSlackPayload(p, event, w.Meta)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetSlackPayload: %v", err)
|
||||||
|
}
|
||||||
|
case models.DISCORD:
|
||||||
|
payloader, err = models.GetDiscordPayload(p, event, w.Meta)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetDiscordPayload: %v", err)
|
||||||
|
}
|
||||||
|
case models.DINGTALK:
|
||||||
|
payloader, err = models.GetDingtalkPayload(p, event, w.Meta)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetDingtalkPayload: %v", err)
|
||||||
|
}
|
||||||
|
case models.TELEGRAM:
|
||||||
|
payloader, err = models.GetTelegramPayload(p, event, w.Meta)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetTelegramPayload: %v", err)
|
||||||
|
}
|
||||||
|
case models.MSTEAMS:
|
||||||
|
payloader, err = models.GetMSTeamsPayload(p, event, w.Meta)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetMSTeamsPayload: %v", err)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
p.SetSecret(w.Secret)
|
||||||
|
payloader = p
|
||||||
|
}
|
||||||
|
|
||||||
|
var signature string
|
||||||
|
if len(w.Secret) > 0 {
|
||||||
|
data, err := payloader.JSONPayload()
|
||||||
|
if err != nil {
|
||||||
|
log.Error("prepareWebhooks.JSONPayload: %v", err)
|
||||||
|
}
|
||||||
|
sig := hmac.New(sha256.New, []byte(w.Secret))
|
||||||
|
_, err = sig.Write(data)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("prepareWebhooks.sigWrite: %v", err)
|
||||||
|
}
|
||||||
|
signature = hex.EncodeToString(sig.Sum(nil))
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = models.CreateHookTask(&models.HookTask{
|
||||||
|
RepoID: repo.ID,
|
||||||
|
HookID: w.ID,
|
||||||
|
Type: w.HookTaskType,
|
||||||
|
URL: w.URL,
|
||||||
|
Signature: signature,
|
||||||
|
Payloader: payloader,
|
||||||
|
HTTPMethod: w.HTTPMethod,
|
||||||
|
ContentType: w.ContentType,
|
||||||
|
EventType: event,
|
||||||
|
IsSSL: w.IsSSL,
|
||||||
|
}); err != nil {
|
||||||
|
return fmt.Errorf("CreateHookTask: %v", err)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrepareWebhooks adds new webhooks to task queue for given payload.
|
||||||
|
func PrepareWebhooks(repo *models.Repository, event models.HookEventType, p api.Payloader) error {
|
||||||
|
if err := prepareWebhooks(repo, event, p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
go hookQueue.Add(repo.ID)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func prepareWebhooks(repo *models.Repository, event models.HookEventType, p api.Payloader) error {
|
||||||
|
ws, err := models.GetActiveWebhooksByRepoID(repo.ID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetActiveWebhooksByRepoID: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if repo belongs to org and append additional webhooks
|
||||||
|
if repo.MustOwner().IsOrganization() {
|
||||||
|
// get hooks for org
|
||||||
|
orgHooks, err := models.GetActiveWebhooksByOrgID(repo.OwnerID)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("GetActiveWebhooksByOrgID: %v", err)
|
||||||
|
}
|
||||||
|
ws = append(ws, orgHooks...)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(ws) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, w := range ws {
|
||||||
|
if err = prepareWebhook(w, repo, event, p); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package webhook
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"code.gitea.io/gitea/models"
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPrepareWebhooks(t *testing.T) {
|
||||||
|
assert.NoError(t, models.PrepareTestDatabase())
|
||||||
|
|
||||||
|
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
|
||||||
|
hookTasks := []*models.HookTask{
|
||||||
|
{RepoID: repo.ID, HookID: 1, EventType: models.HookEventPush},
|
||||||
|
}
|
||||||
|
for _, hookTask := range hookTasks {
|
||||||
|
models.AssertNotExistsBean(t, hookTask)
|
||||||
|
}
|
||||||
|
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{}))
|
||||||
|
for _, hookTask := range hookTasks {
|
||||||
|
models.AssertExistsAndLoadBean(t, hookTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPrepareWebhooksBranchFilterMatch(t *testing.T) {
|
||||||
|
assert.NoError(t, models.PrepareTestDatabase())
|
||||||
|
|
||||||
|
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||||
|
hookTasks := []*models.HookTask{
|
||||||
|
{RepoID: repo.ID, HookID: 4, EventType: models.HookEventPush},
|
||||||
|
}
|
||||||
|
for _, hookTask := range hookTasks {
|
||||||
|
models.AssertNotExistsBean(t, hookTask)
|
||||||
|
}
|
||||||
|
// this test also ensures that * doesn't handle / in any special way (like shell would)
|
||||||
|
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Ref: "refs/heads/feature/7791"}))
|
||||||
|
for _, hookTask := range hookTasks {
|
||||||
|
models.AssertExistsAndLoadBean(t, hookTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPrepareWebhooksBranchFilterNoMatch(t *testing.T) {
|
||||||
|
assert.NoError(t, models.PrepareTestDatabase())
|
||||||
|
|
||||||
|
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 2}).(*models.Repository)
|
||||||
|
hookTasks := []*models.HookTask{
|
||||||
|
{RepoID: repo.ID, HookID: 4, EventType: models.HookEventPush},
|
||||||
|
}
|
||||||
|
for _, hookTask := range hookTasks {
|
||||||
|
models.AssertNotExistsBean(t, hookTask)
|
||||||
|
}
|
||||||
|
assert.NoError(t, PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{Ref: "refs/heads/fix_weird_bug"}))
|
||||||
|
|
||||||
|
for _, hookTask := range hookTasks {
|
||||||
|
models.AssertNotExistsBean(t, hookTask)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO TestHookTask_deliver
|
||||||
|
|
||||||
|
// TODO TestDeliverHooks
|
|
@ -741,6 +741,7 @@ editor.no_changes_to_show=Keine Änderungen vorhanden.
|
||||||
editor.fail_to_update_file=Fehler beim Ändern/Erstellen der Datei „%s“. Fehler: %v
|
editor.fail_to_update_file=Fehler beim Ändern/Erstellen der Datei „%s“. Fehler: %v
|
||||||
editor.add_subdir=Verzeichnis erstellen…
|
editor.add_subdir=Verzeichnis erstellen…
|
||||||
editor.unable_to_upload_files=Fehler beim Hochladen der Dateien nach „%s“. Fehler: %v
|
editor.unable_to_upload_files=Fehler beim Hochladen der Dateien nach „%s“. Fehler: %v
|
||||||
|
editor.upload_file_is_locked=Datei „%s” ist durch %s gesperrt.
|
||||||
editor.upload_files_to_dir=Dateien hochladen nach „%s“
|
editor.upload_files_to_dir=Dateien hochladen nach „%s“
|
||||||
editor.cannot_commit_to_protected_branch=Commit in den geschützten Branch „%s“ ist nicht möglich.
|
editor.cannot_commit_to_protected_branch=Commit in den geschützten Branch „%s“ ist nicht möglich.
|
||||||
|
|
||||||
|
@ -1392,6 +1393,7 @@ settings.lfs_pointers.oid=OID
|
||||||
settings.lfs_pointers.inRepo=Im Repo
|
settings.lfs_pointers.inRepo=Im Repo
|
||||||
settings.lfs_pointers.exists=Existiert im Speicher
|
settings.lfs_pointers.exists=Existiert im Speicher
|
||||||
settings.lfs_pointers.accessible=Nutzer hat Zugriff
|
settings.lfs_pointers.accessible=Nutzer hat Zugriff
|
||||||
|
settings.lfs_pointers.associateAccessible=Ordne %d zugängliche OIDs zu
|
||||||
|
|
||||||
diff.browse_source=Quellcode durchsuchen
|
diff.browse_source=Quellcode durchsuchen
|
||||||
diff.parent=Ursprung
|
diff.parent=Ursprung
|
||||||
|
|
|
@ -742,6 +742,7 @@ editor.no_changes_to_show = There are no changes to show.
|
||||||
editor.fail_to_update_file = Failed to update/create file '%s' with error: %v
|
editor.fail_to_update_file = Failed to update/create file '%s' with error: %v
|
||||||
editor.add_subdir = Add a directory…
|
editor.add_subdir = Add a directory…
|
||||||
editor.unable_to_upload_files = Failed to upload files to '%s' with error: %v
|
editor.unable_to_upload_files = Failed to upload files to '%s' with error: %v
|
||||||
|
editor.upload_file_is_locked = File '%s' is locked by %s.
|
||||||
editor.upload_files_to_dir = Upload files to '%s'
|
editor.upload_files_to_dir = Upload files to '%s'
|
||||||
editor.cannot_commit_to_protected_branch = Cannot commit to protected branch '%s'.
|
editor.cannot_commit_to_protected_branch = Cannot commit to protected branch '%s'.
|
||||||
|
|
||||||
|
|
|
@ -741,6 +741,7 @@ editor.no_changes_to_show=Nenhuma alteração a mostrar.
|
||||||
editor.fail_to_update_file=Houve erro ao criar ou atualizar arquivo '%s': %v
|
editor.fail_to_update_file=Houve erro ao criar ou atualizar arquivo '%s': %v
|
||||||
editor.add_subdir=Adicionar um subdiretório...
|
editor.add_subdir=Adicionar um subdiretório...
|
||||||
editor.unable_to_upload_files=Houve erro ao fazer upload de arquivos para '%s': %v
|
editor.unable_to_upload_files=Houve erro ao fazer upload de arquivos para '%s': %v
|
||||||
|
editor.upload_file_is_locked=Arquivo '%s' está bloqueado por %s.
|
||||||
editor.upload_files_to_dir=Enviar arquivos para '%s'
|
editor.upload_files_to_dir=Enviar arquivos para '%s'
|
||||||
editor.cannot_commit_to_protected_branch=Branch '%s' está protegido para commits.
|
editor.cannot_commit_to_protected_branch=Branch '%s' está protegido para commits.
|
||||||
|
|
||||||
|
|
|
@ -1865,6 +1865,7 @@ delete_branch=<a href="%[1]s">%[3]s</a> deposundan %[2]s dalı silindi
|
||||||
compare_commits=%d işlemeyi karşılaştır
|
compare_commits=%d işlemeyi karşılaştır
|
||||||
compare_commits_general=İşlemeleri karşılaştır
|
compare_commits_general=İşlemeleri karşılaştır
|
||||||
mirror_sync_push=işlemeler yansıdan <a href="%[1]s">%[4]s</a> deposundaki <a href="%[1]s/src/%[2]s">%[3]s</a> dalına eşitlendi
|
mirror_sync_push=işlemeler yansıdan <a href="%[1]s">%[4]s</a> deposundaki <a href="%[1]s/src/%[2]s">%[3]s</a> dalına eşitlendi
|
||||||
|
mirror_sync_create=<a href="%s/src/%s">%[2]s</a> referansı <a href="%[1]s">%[3]s</a> için yansıdan senkronize edildi
|
||||||
mirror_sync_delete=<a href="%[1]s">%[3]s</a> adresindeki <code>%[2]s</code> referansı eşitlendi ve silindi
|
mirror_sync_delete=<a href="%[1]s">%[3]s</a> adresindeki <code>%[2]s</code> referansı eşitlendi ve silindi
|
||||||
|
|
||||||
[tool]
|
[tool]
|
||||||
|
|
|
@ -690,6 +690,11 @@ func RegisterRoutes(m *macaron.Macaron) {
|
||||||
m.Post("/start", reqToken(), repo.StartIssueStopwatch)
|
m.Post("/start", reqToken(), repo.StartIssueStopwatch)
|
||||||
m.Post("/stop", reqToken(), repo.StopIssueStopwatch)
|
m.Post("/stop", reqToken(), repo.StopIssueStopwatch)
|
||||||
})
|
})
|
||||||
|
m.Group("/subscriptions", func() {
|
||||||
|
m.Get("", bind(api.User{}), repo.GetIssueSubscribers)
|
||||||
|
m.Put("/:user", repo.AddIssueSubscription)
|
||||||
|
m.Delete("/:user", repo.DelIssueSubscription)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}, mustEnableIssuesOrPulls)
|
}, mustEnableIssuesOrPulls)
|
||||||
m.Group("/labels", func() {
|
m.Group("/labels", func() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/context"
|
"code.gitea.io/gitea/modules/context"
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
"code.gitea.io/gitea/routers/api/v1/convert"
|
"code.gitea.io/gitea/routers/api/v1/convert"
|
||||||
"code.gitea.io/gitea/routers/api/v1/utils"
|
"code.gitea.io/gitea/routers/api/v1/utils"
|
||||||
)
|
)
|
||||||
|
@ -122,7 +123,7 @@ func TestHook(ctx *context.APIContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.PrepareWebhook(hook, ctx.Repo.Repository, models.HookEventPush, &api.PushPayload{
|
if err := webhook.PrepareWebhook(hook, ctx.Repo.Repository, models.HookEventPush, &api.PushPayload{
|
||||||
Ref: git.BranchPrefix + ctx.Repo.Repository.DefaultBranch,
|
Ref: git.BranchPrefix + ctx.Repo.Repository.DefaultBranch,
|
||||||
Before: ctx.Repo.Commit.ID.String(),
|
Before: ctx.Repo.Commit.ID.String(),
|
||||||
After: ctx.Repo.Commit.ID.String(),
|
After: ctx.Repo.Commit.ID.String(),
|
||||||
|
@ -136,7 +137,7 @@ func TestHook(ctx *context.APIContext) {
|
||||||
ctx.Error(500, "PrepareWebhook: ", err)
|
ctx.Error(500, "PrepareWebhook: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go models.HookQueue.Add(ctx.Repo.Repository.ID)
|
|
||||||
ctx.Status(204)
|
ctx.Status(204)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ import (
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
issue_service "code.gitea.io/gitea/services/issue"
|
issue_service "code.gitea.io/gitea/services/issue"
|
||||||
milestone_service "code.gitea.io/gitea/services/milestone"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SearchIssues searches for issues across the repositories that the user has access to
|
// SearchIssues searches for issues across the repositories that the user has access to
|
||||||
|
@ -494,7 +493,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
|
||||||
issue.MilestoneID != *form.Milestone {
|
issue.MilestoneID != *form.Milestone {
|
||||||
oldMilestoneID := issue.MilestoneID
|
oldMilestoneID := issue.MilestoneID
|
||||||
issue.MilestoneID = *form.Milestone
|
issue.MilestoneID = *form.Milestone
|
||||||
if err = milestone_service.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
|
if err = issue_service.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
|
||||||
ctx.Error(500, "ChangeMilestoneAssign", err)
|
ctx.Error(500, "ChangeMilestoneAssign", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,216 @@
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package repo
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.gitea.io/gitea/models"
|
||||||
|
"code.gitea.io/gitea/modules/context"
|
||||||
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddIssueSubscription Subscribe user to issue
|
||||||
|
func AddIssueSubscription(ctx *context.APIContext) {
|
||||||
|
// swagger:operation PUT /repos/{owner}/{repo}/issues/{index}/subscriptions/{user} issue issueAddSubscription
|
||||||
|
// ---
|
||||||
|
// summary: Subscribe user to issue
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// format: int64
|
||||||
|
// required: true
|
||||||
|
// - name: user
|
||||||
|
// in: path
|
||||||
|
// description: user to subscribe
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "304":
|
||||||
|
// description: User can only subscribe itself if he is no admin
|
||||||
|
// "404":
|
||||||
|
// description: Issue not found
|
||||||
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
|
if err != nil {
|
||||||
|
if models.IsErrIssueNotExist(err) {
|
||||||
|
ctx.NotFound()
|
||||||
|
} else {
|
||||||
|
ctx.Error(500, "GetIssueByIndex", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := models.GetUserByName(ctx.Params(":user"))
|
||||||
|
if err != nil {
|
||||||
|
if models.IsErrUserNotExist(err) {
|
||||||
|
ctx.NotFound()
|
||||||
|
} else {
|
||||||
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//only admin and user for itself can change subscription
|
||||||
|
if user.ID != ctx.User.ID && !ctx.User.IsAdmin {
|
||||||
|
ctx.Error(403, "User", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := models.CreateOrUpdateIssueWatch(user.ID, issue.ID, true); err != nil {
|
||||||
|
ctx.Error(500, "CreateOrUpdateIssueWatch", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Status(201)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelIssueSubscription Unsubscribe user from issue
|
||||||
|
func DelIssueSubscription(ctx *context.APIContext) {
|
||||||
|
// swagger:operation DELETE /repos/{owner}/{repo}/issues/{index}/subscriptions/{user} issue issueDeleteSubscription
|
||||||
|
// ---
|
||||||
|
// summary: Unsubscribe user from issue
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// format: int64
|
||||||
|
// required: true
|
||||||
|
// - name: user
|
||||||
|
// in: path
|
||||||
|
// description: user witch unsubscribe
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "304":
|
||||||
|
// description: User can only subscribe itself if he is no admin
|
||||||
|
// "404":
|
||||||
|
// description: Issue not found
|
||||||
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
|
if err != nil {
|
||||||
|
if models.IsErrIssueNotExist(err) {
|
||||||
|
ctx.NotFound()
|
||||||
|
} else {
|
||||||
|
ctx.Error(500, "GetIssueByIndex", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
user, err := models.GetUserByName(ctx.Params(":user"))
|
||||||
|
if err != nil {
|
||||||
|
if models.IsErrUserNotExist(err) {
|
||||||
|
ctx.NotFound()
|
||||||
|
} else {
|
||||||
|
ctx.Error(500, "GetUserByName", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
//only admin and user for itself can change subscription
|
||||||
|
if user.ID != ctx.User.ID && !ctx.User.IsAdmin {
|
||||||
|
ctx.Error(403, "User", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := models.CreateOrUpdateIssueWatch(user.ID, issue.ID, false); err != nil {
|
||||||
|
ctx.Error(500, "CreateOrUpdateIssueWatch", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Status(201)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetIssueSubscribers return subscribers of an issue
|
||||||
|
func GetIssueSubscribers(ctx *context.APIContext, form api.User) {
|
||||||
|
// swagger:operation GET /repos/{owner}/{repo}/issues/{index}/subscriptions issue issueSubscriptions
|
||||||
|
// ---
|
||||||
|
// summary: Get users who subscribed on an issue.
|
||||||
|
// consumes:
|
||||||
|
// - application/json
|
||||||
|
// produces:
|
||||||
|
// - application/json
|
||||||
|
// parameters:
|
||||||
|
// - name: owner
|
||||||
|
// in: path
|
||||||
|
// description: owner of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: repo
|
||||||
|
// in: path
|
||||||
|
// description: name of the repo
|
||||||
|
// type: string
|
||||||
|
// required: true
|
||||||
|
// - name: index
|
||||||
|
// in: path
|
||||||
|
// description: index of the issue
|
||||||
|
// type: integer
|
||||||
|
// format: int64
|
||||||
|
// required: true
|
||||||
|
// responses:
|
||||||
|
// "201":
|
||||||
|
// "$ref": "#/responses/empty"
|
||||||
|
// "404":
|
||||||
|
// description: Issue not found
|
||||||
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
|
||||||
|
if err != nil {
|
||||||
|
if models.IsErrIssueNotExist(err) {
|
||||||
|
ctx.NotFound()
|
||||||
|
} else {
|
||||||
|
ctx.Error(500, "GetIssueByIndex", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
iwl, err := models.GetIssueWatchers(issue.ID)
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(500, "GetIssueWatchers", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
users, err := iwl.LoadWatchUsers()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Error(500, "LoadWatchUsers", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.JSON(200, users.APIFormat())
|
||||||
|
}
|
|
@ -18,7 +18,6 @@ import (
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
issue_service "code.gitea.io/gitea/services/issue"
|
issue_service "code.gitea.io/gitea/services/issue"
|
||||||
milestone_service "code.gitea.io/gitea/services/milestone"
|
|
||||||
pull_service "code.gitea.io/gitea/services/pull"
|
pull_service "code.gitea.io/gitea/services/pull"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -420,7 +419,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) {
|
||||||
issue.MilestoneID != form.Milestone {
|
issue.MilestoneID != form.Milestone {
|
||||||
oldMilestoneID := issue.MilestoneID
|
oldMilestoneID := issue.MilestoneID
|
||||||
issue.MilestoneID = form.Milestone
|
issue.MilestoneID = form.Milestone
|
||||||
if err = milestone_service.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
|
if err = issue_service.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
|
||||||
ctx.Error(500, "ChangeMilestoneAssign", err)
|
ctx.Error(500, "ChangeMilestoneAssign", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
"code.gitea.io/gitea/modules/ssh"
|
"code.gitea.io/gitea/modules/ssh"
|
||||||
"code.gitea.io/gitea/modules/task"
|
"code.gitea.io/gitea/modules/task"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
"code.gitea.io/gitea/services/mailer"
|
"code.gitea.io/gitea/services/mailer"
|
||||||
mirror_service "code.gitea.io/gitea/services/mirror"
|
mirror_service "code.gitea.io/gitea/services/mirror"
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ func GlobalInit() {
|
||||||
issue_indexer.InitIssueIndexer(false)
|
issue_indexer.InitIssueIndexer(false)
|
||||||
models.InitRepoIndexer()
|
models.InitRepoIndexer()
|
||||||
mirror_service.InitSyncMirrors()
|
mirror_service.InitSyncMirrors()
|
||||||
models.InitDeliverHooks()
|
webhook.InitDeliverHooks()
|
||||||
models.InitTestPullRequests()
|
models.InitTestPullRequests()
|
||||||
if err := task.Init(); err != nil {
|
if err := task.Init(); err != nil {
|
||||||
log.Fatal("Failed to initialize task scheduler: %v", err)
|
log.Fatal("Failed to initialize task scheduler: %v", err)
|
||||||
|
|
|
@ -585,7 +585,11 @@ func UploadFilePost(ctx *context.Context, form auth.UploadRepoFileForm) {
|
||||||
Files: form.Files,
|
Files: form.Files,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
ctx.Data["Err_TreePath"] = true
|
ctx.Data["Err_TreePath"] = true
|
||||||
|
if models.IsErrLFSFileLocked(err) {
|
||||||
|
ctx.RenderWithErr(ctx.Tr("repo.editor.upload_file_is_locked", err.(models.ErrLFSFileLocked).Path, err.(models.ErrLFSFileLocked).UserName), tplUploadFile, &form)
|
||||||
|
} else {
|
||||||
ctx.RenderWithErr(ctx.Tr("repo.editor.unable_to_upload_files", form.TreePath, err), tplUploadFile, &form)
|
ctx.RenderWithErr(ctx.Tr("repo.editor.unable_to_upload_files", form.TreePath, err), tplUploadFile, &form)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@ import (
|
||||||
"code.gitea.io/gitea/modules/util"
|
"code.gitea.io/gitea/modules/util"
|
||||||
comment_service "code.gitea.io/gitea/services/comments"
|
comment_service "code.gitea.io/gitea/services/comments"
|
||||||
issue_service "code.gitea.io/gitea/services/issue"
|
issue_service "code.gitea.io/gitea/services/issue"
|
||||||
milestone_service "code.gitea.io/gitea/services/milestone"
|
|
||||||
|
|
||||||
"github.com/unknwon/com"
|
"github.com/unknwon/com"
|
||||||
)
|
)
|
||||||
|
@ -1099,7 +1098,7 @@ func UpdateIssueMilestone(ctx *context.Context) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
issue.MilestoneID = milestoneID
|
issue.MilestoneID = milestoneID
|
||||||
if err := milestone_service.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
|
if err := issue_service.ChangeMilestoneAssign(issue, ctx.User, oldMilestoneID); err != nil {
|
||||||
ctx.ServerError("ChangeMilestoneAssign", err)
|
ctx.ServerError("ChangeMilestoneAssign", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -823,7 +823,6 @@ func TriggerTask(ctx *context.Context) {
|
||||||
|
|
||||||
log.Trace("TriggerTask '%s/%s' by %s", repo.Name, branch, pusher.Name)
|
log.Trace("TriggerTask '%s/%s' by %s", repo.Name, branch, pusher.Name)
|
||||||
|
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
go pull_service.AddTestPullRequestTask(pusher, repo.ID, branch, true)
|
go pull_service.AddTestPullRequestTask(pusher, repo.ID, branch, true)
|
||||||
ctx.Status(202)
|
ctx.Status(202)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
|
|
||||||
"github.com/unknwon/com"
|
"github.com/unknwon/com"
|
||||||
)
|
)
|
||||||
|
@ -864,11 +865,10 @@ func TestWebhook(ctx *context.Context) {
|
||||||
Pusher: apiUser,
|
Pusher: apiUser,
|
||||||
Sender: apiUser,
|
Sender: apiUser,
|
||||||
}
|
}
|
||||||
if err := models.PrepareWebhook(w, ctx.Repo.Repository, models.HookEventPush, p); err != nil {
|
if err := webhook.PrepareWebhook(w, ctx.Repo.Repository, models.HookEventPush, p); err != nil {
|
||||||
ctx.Flash.Error("PrepareWebhook: " + err.Error())
|
ctx.Flash.Error("PrepareWebhook: " + err.Error())
|
||||||
ctx.Status(500)
|
ctx.Status(500)
|
||||||
} else {
|
} else {
|
||||||
go models.HookQueue.Add(ctx.Repo.Repository.ID)
|
|
||||||
ctx.Flash.Info(ctx.Tr("repo.settings.webhook.test_delivery_success"))
|
ctx.Flash.Info(ctx.Tr("repo.settings.webhook.test_delivery_success"))
|
||||||
ctx.Status(200)
|
ctx.Status(200)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,57 +6,9 @@ package issue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/log"
|
|
||||||
"code.gitea.io/gitea/modules/notification"
|
"code.gitea.io/gitea/modules/notification"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func sendLabelUpdatedWebhook(issue *models.Issue, doer *models.User) {
|
|
||||||
var err error
|
|
||||||
|
|
||||||
if err = issue.LoadRepo(); err != nil {
|
|
||||||
log.Error("LoadRepo: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = issue.LoadPoster(); err != nil {
|
|
||||||
log.Error("LoadPoster: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
|
|
||||||
if issue.IsPull {
|
|
||||||
if err = issue.LoadPullRequest(); err != nil {
|
|
||||||
log.Error("loadPullRequest: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err = issue.PullRequest.LoadIssue(); err != nil {
|
|
||||||
log.Error("LoadIssue: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
|
||||||
Action: api.HookIssueLabelUpdated,
|
|
||||||
Index: issue.Index,
|
|
||||||
PullRequest: issue.PullRequest.APIFormat(),
|
|
||||||
Repository: issue.Repo.APIFormat(models.AccessModeNone),
|
|
||||||
Sender: doer.APIFormat(),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
|
||||||
Action: api.HookIssueLabelUpdated,
|
|
||||||
Index: issue.Index,
|
|
||||||
Issue: issue.APIFormat(),
|
|
||||||
Repository: issue.Repo.APIFormat(mode),
|
|
||||||
Sender: doer.APIFormat(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ClearLabels clears all of an issue's labels
|
// ClearLabels clears all of an issue's labels
|
||||||
func ClearLabels(issue *models.Issue, doer *models.User) (err error) {
|
func ClearLabels(issue *models.Issue, doer *models.User) (err error) {
|
||||||
if err = issue.ClearLabels(doer); err != nil {
|
if err = issue.ClearLabels(doer); err != nil {
|
||||||
|
@ -74,7 +26,7 @@ func AddLabel(issue *models.Issue, doer *models.User, label *models.Label) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sendLabelUpdatedWebhook(issue, doer)
|
notification.NotifyIssueChangeLabels(doer, issue, []*models.Label{label}, nil)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +36,7 @@ func AddLabels(issue *models.Issue, doer *models.User, labels []*models.Label) e
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sendLabelUpdatedWebhook(issue, doer)
|
notification.NotifyIssueChangeLabels(doer, issue, labels, nil)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +58,6 @@ func RemoveLabel(issue *models.Issue, doer *models.User, label *models.Label) er
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sendLabelUpdatedWebhook(issue, doer)
|
notification.NotifyIssueChangeLabels(doer, issue, nil, []*models.Label{label})
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a MIT-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package issue
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.gitea.io/gitea/models"
|
||||||
|
"code.gitea.io/gitea/modules/notification"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ChangeMilestoneAssign changes assignment of milestone for issue.
|
||||||
|
func ChangeMilestoneAssign(issue *models.Issue, doer *models.User, oldMilestoneID int64) (err error) {
|
||||||
|
if err = models.ChangeMilestoneAssign(issue, doer, oldMilestoneID); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
notification.NotifyIssueChangeMilestone(doer, issue, oldMilestoneID)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -1,59 +0,0 @@
|
||||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a MIT-style
|
|
||||||
// license that can be found in the LICENSE file.
|
|
||||||
|
|
||||||
package models
|
|
||||||
|
|
||||||
import (
|
|
||||||
"code.gitea.io/gitea/models"
|
|
||||||
"code.gitea.io/gitea/modules/log"
|
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ChangeMilestoneAssign changes assignment of milestone for issue.
|
|
||||||
func ChangeMilestoneAssign(issue *models.Issue, doer *models.User, oldMilestoneID int64) (err error) {
|
|
||||||
if err = models.ChangeMilestoneAssign(issue, doer, oldMilestoneID); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var hookAction api.HookIssueAction
|
|
||||||
if issue.MilestoneID > 0 {
|
|
||||||
hookAction = api.HookIssueMilestoned
|
|
||||||
} else {
|
|
||||||
hookAction = api.HookIssueDemilestoned
|
|
||||||
}
|
|
||||||
|
|
||||||
if err = issue.LoadAttributes(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
mode, _ := models.AccessLevel(doer, issue.Repo)
|
|
||||||
if issue.IsPull {
|
|
||||||
err = issue.PullRequest.LoadIssue()
|
|
||||||
if err != nil {
|
|
||||||
log.Error("LoadIssue: %v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
|
||||||
Action: hookAction,
|
|
||||||
Index: issue.Index,
|
|
||||||
PullRequest: issue.PullRequest.APIFormat(),
|
|
||||||
Repository: issue.Repo.APIFormat(mode),
|
|
||||||
Sender: doer.APIFormat(),
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
err = models.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
|
|
||||||
Action: hookAction,
|
|
||||||
Index: issue.Index,
|
|
||||||
Issue: issue.APIFormat(),
|
|
||||||
Repository: issue.Repo.APIFormat(mode),
|
|
||||||
Sender: doer.APIFormat(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
log.Error("PrepareWebhooks [is_pull: %v]: %v", issue.IsPull, err)
|
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(issue.RepoID)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
)
|
)
|
||||||
|
|
||||||
func syncAction(opType models.ActionType, repo *models.Repository, refName string, data []byte) error {
|
func syncAction(opType models.ActionType, repo *models.Repository, refName string, data []byte) error {
|
||||||
|
@ -27,10 +28,6 @@ func syncAction(opType models.ActionType, repo *models.Repository, refName strin
|
||||||
return fmt.Errorf("notifyWatchers: %v", err)
|
return fmt.Errorf("notifyWatchers: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
}()
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +52,7 @@ func SyncPushAction(repo *models.Repository, opts SyncPushActionOptions) error {
|
||||||
|
|
||||||
opts.Commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID)
|
opts.Commits.CompareURL = repo.ComposeCompareURL(opts.OldCommitID, opts.NewCommitID)
|
||||||
apiPusher := repo.MustOwner().APIFormat()
|
apiPusher := repo.MustOwner().APIFormat()
|
||||||
if err := models.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
|
if err := webhook.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
|
||||||
Ref: opts.RefName,
|
Ref: opts.RefName,
|
||||||
Before: opts.OldCommitID,
|
Before: opts.OldCommitID,
|
||||||
After: opts.NewCommitID,
|
After: opts.NewCommitID,
|
||||||
|
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
|
|
||||||
"github.com/mcuadros/go-version"
|
"github.com/mcuadros/go-version"
|
||||||
)
|
)
|
||||||
|
@ -360,7 +361,7 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
|
||||||
}
|
}
|
||||||
|
|
||||||
mode, _ := models.AccessLevel(doer, pr.Issue.Repo)
|
mode, _ := models.AccessLevel(doer, pr.Issue.Repo)
|
||||||
if err = models.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
if err = webhook.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueClosed,
|
Action: api.HookIssueClosed,
|
||||||
Index: pr.Index,
|
Index: pr.Index,
|
||||||
PullRequest: pr.APIFormat(),
|
PullRequest: pr.APIFormat(),
|
||||||
|
@ -368,8 +369,6 @@ func Merge(pr *models.PullRequest, doer *models.User, baseGitRepo *git.Repositor
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks: %v", err)
|
log.Error("PrepareWebhooks: %v", err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(pr.Issue.Repo.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/git"
|
"code.gitea.io/gitea/modules/git"
|
||||||
"code.gitea.io/gitea/modules/log"
|
"code.gitea.io/gitea/modules/log"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
issue_service "code.gitea.io/gitea/services/issue"
|
issue_service "code.gitea.io/gitea/services/issue"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
|
||||||
pr.Issue = pull
|
pr.Issue = pull
|
||||||
pull.PullRequest = pr
|
pull.PullRequest = pr
|
||||||
mode, _ := models.AccessLevel(pull.Poster, repo)
|
mode, _ := models.AccessLevel(pull.Poster, repo)
|
||||||
if err := models.PrepareWebhooks(repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
if err := webhook.PrepareWebhooks(repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueOpened,
|
Action: api.HookIssueOpened,
|
||||||
Index: pull.Index,
|
Index: pull.Index,
|
||||||
PullRequest: pr.APIFormat(),
|
PullRequest: pr.APIFormat(),
|
||||||
|
@ -49,8 +50,6 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
|
||||||
Sender: pull.Poster.APIFormat(),
|
Sender: pull.Poster.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks: %v", err)
|
log.Error("PrepareWebhooks: %v", err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(repo.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -114,7 +113,7 @@ func AddTestPullRequestTask(doer *models.User, repoID int64, branch string, isSy
|
||||||
log.Error("LoadAttributes: %v", err)
|
log.Error("LoadAttributes: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err = models.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
if err = webhook.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueSynchronized,
|
Action: api.HookIssueSynchronized,
|
||||||
Index: pr.Issue.Index,
|
Index: pr.Issue.Index,
|
||||||
PullRequest: pr.Issue.PullRequest.APIFormat(),
|
PullRequest: pr.Issue.PullRequest.APIFormat(),
|
||||||
|
@ -124,7 +123,6 @@ func AddTestPullRequestTask(doer *models.User, repoID int64, branch string, isSy
|
||||||
log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err)
|
log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
go models.HookQueue.Add(pr.Issue.Repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ package pull
|
||||||
import (
|
import (
|
||||||
"code.gitea.io/gitea/models"
|
"code.gitea.io/gitea/models"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CreateReview creates a new review based on opts
|
// CreateReview creates a new review based on opts
|
||||||
|
@ -55,7 +56,7 @@ func reviewHook(review *models.Review) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := models.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{
|
return webhook.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueSynchronized,
|
Action: api.HookIssueSynchronized,
|
||||||
Index: review.Issue.Index,
|
Index: review.Issue.Index,
|
||||||
PullRequest: pr.APIFormat(),
|
PullRequest: pr.APIFormat(),
|
||||||
|
@ -65,10 +66,5 @@ func reviewHook(review *models.Review) error {
|
||||||
Type: string(reviewHookType),
|
Type: string(reviewHookType),
|
||||||
Content: review.Content,
|
Content: review.Content,
|
||||||
},
|
},
|
||||||
}); err != nil {
|
})
|
||||||
return err
|
|
||||||
}
|
|
||||||
go models.HookQueue.Add(review.Issue.Repo.ID)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import (
|
||||||
"code.gitea.io/gitea/modules/process"
|
"code.gitea.io/gitea/modules/process"
|
||||||
api "code.gitea.io/gitea/modules/structs"
|
api "code.gitea.io/gitea/modules/structs"
|
||||||
"code.gitea.io/gitea/modules/timeutil"
|
"code.gitea.io/gitea/modules/timeutil"
|
||||||
|
"code.gitea.io/gitea/modules/webhook"
|
||||||
)
|
)
|
||||||
|
|
||||||
func createTag(gitRepo *git.Repository, rel *models.Release) error {
|
func createTag(gitRepo *git.Repository, rel *models.Release) error {
|
||||||
|
@ -84,15 +85,13 @@ func CreateRelease(gitRepo *git.Repository, rel *models.Release, attachmentUUIDs
|
||||||
log.Error("LoadAttributes: %v", err)
|
log.Error("LoadAttributes: %v", err)
|
||||||
} else {
|
} else {
|
||||||
mode, _ := models.AccessLevel(rel.Publisher, rel.Repo)
|
mode, _ := models.AccessLevel(rel.Publisher, rel.Repo)
|
||||||
if err := models.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
|
if err := webhook.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
|
||||||
Action: api.HookReleasePublished,
|
Action: api.HookReleasePublished,
|
||||||
Release: rel.APIFormat(),
|
Release: rel.APIFormat(),
|
||||||
Repository: rel.Repo.APIFormat(mode),
|
Repository: rel.Repo.APIFormat(mode),
|
||||||
Sender: rel.Publisher.APIFormat(),
|
Sender: rel.Publisher.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks: %v", err)
|
log.Error("PrepareWebhooks: %v", err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(rel.Repo.ID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,15 +120,13 @@ func UpdateRelease(doer *models.User, gitRepo *git.Repository, rel *models.Relea
|
||||||
|
|
||||||
// even if attachments added failed, hooks will be still triggered
|
// even if attachments added failed, hooks will be still triggered
|
||||||
mode, _ := models.AccessLevel(doer, rel.Repo)
|
mode, _ := models.AccessLevel(doer, rel.Repo)
|
||||||
if err1 := models.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
|
if err1 := webhook.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
|
||||||
Action: api.HookReleaseUpdated,
|
Action: api.HookReleaseUpdated,
|
||||||
Release: rel.APIFormat(),
|
Release: rel.APIFormat(),
|
||||||
Repository: rel.Repo.APIFormat(mode),
|
Repository: rel.Repo.APIFormat(mode),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}); err1 != nil {
|
}); err1 != nil {
|
||||||
log.Error("PrepareWebhooks: %v", err)
|
log.Error("PrepareWebhooks: %v", err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(rel.Repo.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
@ -187,15 +184,13 @@ func DeleteReleaseByID(id int64, doer *models.User, delTag bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
mode, _ := models.AccessLevel(doer, rel.Repo)
|
mode, _ := models.AccessLevel(doer, rel.Repo)
|
||||||
if err := models.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
|
if err := webhook.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
|
||||||
Action: api.HookReleaseDeleted,
|
Action: api.HookReleaseDeleted,
|
||||||
Release: rel.APIFormat(),
|
Release: rel.APIFormat(),
|
||||||
Repository: rel.Repo.APIFormat(mode),
|
Repository: rel.Repo.APIFormat(mode),
|
||||||
Sender: doer.APIFormat(),
|
Sender: doer.APIFormat(),
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
log.Error("PrepareWebhooks: %v", err)
|
log.Error("PrepareWebhooks: %v", err)
|
||||||
} else {
|
|
||||||
go models.HookQueue.Add(rel.Repo.ID)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
<div class="ui attached table segment">
|
||||||
|
<table class="ui very basic striped fixed table single line" id="commits-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
|
||||||
|
<th class="two wide sha">SHA1</th>
|
||||||
|
<th class="seven wide message">{{.i18n.Tr "repo.commits.message"}}</th>
|
||||||
|
<th class="three wide right aligned">{{.i18n.Tr "repo.commits.date"}}</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="commit-list">
|
||||||
|
{{ $r:= List .Commits}}
|
||||||
|
{{range $r}}
|
||||||
|
<tr>
|
||||||
|
<td class="author">
|
||||||
|
{{$userName := .Author.Name}}
|
||||||
|
{{if .User}}
|
||||||
|
{{if .User.FullName}}
|
||||||
|
{{$userName = .User.FullName}}
|
||||||
|
{{end}}
|
||||||
|
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{$userName}}</a>
|
||||||
|
{{else}}
|
||||||
|
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/> {{$userName}}
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
|
<td class="sha">
|
||||||
|
{{$class := "ui sha label"}}
|
||||||
|
{{if .Signature}}
|
||||||
|
{{$class = (printf "%s%s" $class " isSigned")}}
|
||||||
|
{{if .Verification.Verified}}
|
||||||
|
{{$class = (printf "%s%s" $class " isVerified")}}
|
||||||
|
{{else if .Verification.Warning}}
|
||||||
|
{{$class = (printf "%s%s" $class " isWarning")}}
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
{{if $.Reponame}}
|
||||||
|
<a href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}" rel="nofollow" class="{{$class}}">
|
||||||
|
{{else}}
|
||||||
|
<span class="{{$class}}">
|
||||||
|
{{end}}
|
||||||
|
{{ShortSha .ID.String}}
|
||||||
|
{{if .Signature}}
|
||||||
|
<div class="ui detail icon button">
|
||||||
|
{{if .Verification.Verified}}
|
||||||
|
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
|
||||||
|
{{if ne .Verification.SigningUser.ID 0}}
|
||||||
|
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
|
||||||
|
{{else}}
|
||||||
|
<i title="{{.Verification.Reason}}" class="icons">
|
||||||
|
<i class="green lock icon"></i>
|
||||||
|
<i class="tiny inverted cog icon centerlock"></i>
|
||||||
|
</i>
|
||||||
|
{{end}}
|
||||||
|
{{else if .Verification.Warning}}
|
||||||
|
<i title="{{$.i18n.Tr .Verification.Reason}}" class="red unlock icon"></i>
|
||||||
|
{{else}}
|
||||||
|
<i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
{{if $.Reponame}}
|
||||||
|
</a>
|
||||||
|
{{else}}
|
||||||
|
</span>
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
|
<td class="message">
|
||||||
|
<span class="message-wrapper">
|
||||||
|
{{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }}
|
||||||
|
<span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
|
||||||
|
</span>
|
||||||
|
{{if IsMultilineCommitMessage .Message}}
|
||||||
|
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
|
||||||
|
{{end}}
|
||||||
|
{{if eq (CommitType .) "SignCommitWithStatuses"}}
|
||||||
|
{{template "repo/commit_status" .Status}}
|
||||||
|
{{end}}
|
||||||
|
{{if IsMultilineCommitMessage .Message}}
|
||||||
|
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
|
||||||
|
{{end}}
|
||||||
|
</td>
|
||||||
|
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
|
@ -30,73 +30,7 @@
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
{{if and .Commits (gt .CommitCount 0)}}
|
{{if and .Commits (gt .CommitCount 0)}}
|
||||||
<div class="ui attached table segment">
|
{{template "repo/commits_list" .}}
|
||||||
<table class="ui very basic striped fixed table single line" id="commits-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
|
|
||||||
<th class="two wide sha">SHA1</th>
|
|
||||||
<th class="seven wide message">{{.i18n.Tr "repo.commits.message"}}</th>
|
|
||||||
<th class="three wide right aligned">{{.i18n.Tr "repo.commits.date"}}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="commit-list">
|
|
||||||
{{ $r:= List .Commits}}
|
|
||||||
{{range $r}}
|
|
||||||
<tr>
|
|
||||||
<td class="author">
|
|
||||||
{{if .User}}
|
|
||||||
{{if .User.FullName}}
|
|
||||||
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.User.FullName}}</a>
|
|
||||||
{{else}}
|
|
||||||
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
|
|
||||||
{{end}}
|
|
||||||
{{else}}
|
|
||||||
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/> {{.Author.Name}}
|
|
||||||
{{end}}
|
|
||||||
</td>
|
|
||||||
<td class="sha">
|
|
||||||
<a rel="nofollow" class="ui sha label {{if .Signature}} isSigned {{if .Verification.Verified }} isVerified {{else if .Verification.Warning}} isWarning {{end}}{{end}}" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">
|
|
||||||
{{ShortSha .ID.String}}
|
|
||||||
{{if .Signature}}
|
|
||||||
<div class="ui detail icon button">
|
|
||||||
{{if .Verification.Verified}}
|
|
||||||
{{if ne .Verification.SigningUser.ID 0}}
|
|
||||||
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
|
|
||||||
{{else}}
|
|
||||||
<i title="{{.Verification.Reason}}" class="icons">
|
|
||||||
<i class="green lock icon"></i>
|
|
||||||
<i class="tiny inverted cog icon centerlock"></i>
|
|
||||||
</i>
|
|
||||||
{{end}}
|
|
||||||
{{else if .Verification.Warning}}
|
|
||||||
<i title="{{$.i18n.Tr .Verification.Reason}}" class="red unlock icon"></i>
|
|
||||||
{{else}}
|
|
||||||
<i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td class="message">
|
|
||||||
<span class="message-wrapper">
|
|
||||||
{{ $commitLink:= printf "%s/%s/%s/commit/%s" AppSubUrl $.Username $.Reponame .ID }}
|
|
||||||
<span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{RenderCommitMessageLinkSubject .Message $.RepoLink $commitLink $.Repository.ComposeMetas}}</span>
|
|
||||||
</span>
|
|
||||||
{{if IsMultilineCommitMessage .Message}}
|
|
||||||
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
|
|
||||||
{{end}}
|
|
||||||
{{template "repo/commit_status" .Status}}
|
|
||||||
{{if IsMultilineCommitMessage .Message}}
|
|
||||||
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
|
|
||||||
{{end}}
|
|
||||||
</td>
|
|
||||||
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
|
|
||||||
</tr>
|
|
||||||
{{end}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<table id="repo-files-table" class="ui single line table fixed">
|
<table id="repo-files-table" class="ui single line table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="commit-list">
|
<tr class="commit-list">
|
||||||
<th colspan="2">
|
<th colspan="2">
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
{{else}}
|
{{else}}
|
||||||
<td class="name">
|
<td class="name four wide">
|
||||||
<span class="truncate">
|
<span class="truncate">
|
||||||
{{if $entry.IsDir}}
|
{{if $entry.IsDir}}
|
||||||
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
|
{{$subJumpablePathName := $entry.GetSubJumpablePathName}}
|
||||||
|
@ -82,12 +82,12 @@
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
{{end}}
|
{{end}}
|
||||||
<td class="message">
|
<td class="message nine wide">
|
||||||
<span class="truncate has-emoji">
|
<span class="truncate has-emoji">
|
||||||
<a href="{{$.RepoLink}}/commit/{{$commit.ID}}" title="{{$commit.Summary}}">{{$commit.Summary}}</a>
|
<a href="{{$.RepoLink}}/commit/{{$commit.ID}}" title="{{$commit.Summary}}">{{$commit.Summary}}</a>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="text grey right age">{{TimeSince $commit.Committer.When $.Lang}}</td>
|
<td class="text grey right age three wide">{{TimeSince $commit.Committer.When $.Lang}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
@ -48,60 +48,7 @@
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
{{if and .Commits (gt .CommitCount 0)}}
|
{{if and .Commits (gt .CommitCount 0)}}
|
||||||
<div class="ui attached table segment">
|
{{template "repo/commits_list" .}}
|
||||||
<table class="ui very basic striped fixed table single line" id="commits-table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="four wide">{{.i18n.Tr "repo.commits.author"}}</th>
|
|
||||||
<th class="tree wide sha">SHA1</th>
|
|
||||||
<th class="five wide message">{{.i18n.Tr "repo.commits.message"}}</th>
|
|
||||||
<th class="four wide">{{.i18n.Tr "repo.commits.date"}}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="commit-list">
|
|
||||||
{{ $r:= List .Commits}}
|
|
||||||
{{range $r}}
|
|
||||||
<tr>
|
|
||||||
<td class="author">
|
|
||||||
{{if .User}}
|
|
||||||
{{if .User.FullName}}
|
|
||||||
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.User.FullName}}</a>
|
|
||||||
{{else}}
|
|
||||||
<img class="ui avatar image" src="{{.User.RelAvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
|
|
||||||
{{end}}
|
|
||||||
{{else}}
|
|
||||||
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/> {{.Author.Name}}
|
|
||||||
{{end}}
|
|
||||||
</td>
|
|
||||||
<td class="sha">
|
|
||||||
<label rel="nofollow" class="ui sha label {{if .Signature}} isSigned {{if .Verification.Verified }} isVerified {{end}}{{end}}">
|
|
||||||
{{ShortSha .ID.String}}
|
|
||||||
{{if .Signature}}
|
|
||||||
<div class="ui detail icon button">
|
|
||||||
{{if .Verification.Verified}}
|
|
||||||
<i title="{{.Verification.Reason}}" class="lock green icon"></i>
|
|
||||||
{{else}}
|
|
||||||
<i title="{{$.i18n.Tr .Verification.Reason}}" class="unlock icon"></i>
|
|
||||||
{{end}}
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
<td class="message">
|
|
||||||
<span class="message-wrapper">
|
|
||||||
<span class="commit-summary has-emoji{{if gt .ParentCount 1}} grey text{{end}}" title="{{.Summary}}">{{.Summary}}</span>
|
|
||||||
{{if IsMultilineCommitMessage .Message}}
|
|
||||||
<button class="basic compact mini ui icon button commit-button"><i class="ellipsis horizontal icon"></i></button>
|
|
||||||
<pre class="commit-body" style="display: none;">{{RenderCommitBody .Message $.RepoLink $.Repository.ComposeMetas}}</pre>
|
|
||||||
{{end}}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td class="grey text">{{TimeSince .Author.When $.Lang}}</td>
|
|
||||||
</tr>
|
|
||||||
{{end}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{template "base/paginate" .}}
|
{{template "base/paginate" .}}
|
||||||
|
|
|
@ -3781,6 +3781,165 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/repos/{owner}/{repo}/issues/{index}/subscriptions": {
|
||||||
|
"get": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"issue"
|
||||||
|
],
|
||||||
|
"summary": "Get users who subscribed on an issue.",
|
||||||
|
"operationId": "issueSubscriptions",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "index of the issue",
|
||||||
|
"name": "index",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"$ref": "#/responses/empty"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Issue not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/repos/{owner}/{repo}/issues/{index}/subscriptions/{user}": {
|
||||||
|
"put": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"issue"
|
||||||
|
],
|
||||||
|
"summary": "Subscribe user to issue",
|
||||||
|
"operationId": "issueAddSubscription",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "index of the issue",
|
||||||
|
"name": "index",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "user to subscribe",
|
||||||
|
"name": "user",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"$ref": "#/responses/empty"
|
||||||
|
},
|
||||||
|
"304": {
|
||||||
|
"description": "User can only subscribe itself if he is no admin"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Issue not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"issue"
|
||||||
|
],
|
||||||
|
"summary": "Unsubscribe user from issue",
|
||||||
|
"operationId": "issueDeleteSubscription",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "owner of the repo",
|
||||||
|
"name": "owner",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "name of the repo",
|
||||||
|
"name": "repo",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"format": "int64",
|
||||||
|
"description": "index of the issue",
|
||||||
|
"name": "index",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "user witch unsubscribe",
|
||||||
|
"name": "user",
|
||||||
|
"in": "path",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"201": {
|
||||||
|
"$ref": "#/responses/empty"
|
||||||
|
},
|
||||||
|
"304": {
|
||||||
|
"description": "User can only subscribe itself if he is no admin"
|
||||||
|
},
|
||||||
|
"404": {
|
||||||
|
"description": "Issue not found"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/repos/{owner}/{repo}/keys": {
|
"/repos/{owner}/{repo}/keys": {
|
||||||
"get": {
|
"get": {
|
||||||
"produces": [
|
"produces": [
|
||||||
|
|
Loading…
Reference in New Issue