.
This commit is contained in:
parent
6d650d68b1
commit
18bfc87a1c
@ -44,7 +44,6 @@ const (
|
|||||||
ReviewStateUnknown models.ReviewStateType = ""
|
ReviewStateUnknown models.ReviewStateType = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
func (h *RequestHandler) GetPullRequestAndReviews(org, project string, num int64) (*models.PullRequest, []*models.PullReview, error) {
|
func (h *RequestHandler) GetPullRequestAndReviews(org, project string, num int64) (*models.PullRequest, []*models.PullReview, error) {
|
||||||
if h.HasError() {
|
if h.HasError() {
|
||||||
return nil, nil, h.Error
|
return nil, nil, h.Error
|
||||||
@ -61,7 +60,7 @@ func (h *RequestHandler) GetPullRequestAndReviews(org, project string, num int64
|
|||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.Error = err;
|
h.Error = err
|
||||||
h.LogPlainError(err)
|
h.LogPlainError(err)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
@ -335,3 +334,31 @@ func (h *RequestHandler) GetAssociatedPrjGitPR(pr *PullRequestAction) *models.Pu
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *RequestHandler) GetRepositoryFileContent(pr *models.PullRequest, path string) ([]byte, error) {
|
||||||
|
if h.HasError() {
|
||||||
|
return nil, h.Error
|
||||||
|
}
|
||||||
|
|
||||||
|
transport, client := h.allocateGiteaTransport()
|
||||||
|
repo := pr.Head.Repo
|
||||||
|
file, err := client.Repository.RepoGetRawFile(
|
||||||
|
repository.NewRepoGetRawFileParams().
|
||||||
|
WithOwner(repo.Owner.UserName).
|
||||||
|
WithRepo(repo.Name).
|
||||||
|
WithFilepath(path).
|
||||||
|
WithRef(&pr.Head.Ref),
|
||||||
|
transport.DefaultAuthentication,
|
||||||
|
)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !file.IsSuccess() {
|
||||||
|
return nil, fmt.Errorf("Invalid response from server (%d): %s", file.Code(), file.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
return file.Body(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@ type ObsClient struct {
|
|||||||
client *http.Client
|
client *http.Client
|
||||||
user, password string
|
user, password string
|
||||||
cookie string
|
cookie string
|
||||||
|
|
||||||
|
HomeProject string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewObsClient(host string) (*ObsClient, error) {
|
func NewObsClient(host string) (*ObsClient, error) {
|
||||||
@ -27,6 +29,8 @@ func NewObsClient(host string) (*ObsClient, error) {
|
|||||||
client: &http.Client{},
|
client: &http.Client{},
|
||||||
user: obsUser,
|
user: obsUser,
|
||||||
password: obsPassword,
|
password: obsPassword,
|
||||||
|
|
||||||
|
HomeProject: fmt.Sprintf("home:%s", obsUser),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +70,7 @@ func processPullNotification(h *common.RequestHandler, notification *models.Noti
|
|||||||
|
|
||||||
switch review.State {
|
switch review.State {
|
||||||
case common.ReviewStateUnknown, common.ReviewStateRequestReview:
|
case common.ReviewStateUnknown, common.ReviewStateRequestReview:
|
||||||
|
|
||||||
// create build project, if doesn't exist, and add it to pending requests
|
// create build project, if doesn't exist, and add it to pending requests
|
||||||
case common.ReviewStatePending:
|
case common.ReviewStatePending:
|
||||||
// waiting for build results
|
// waiting for build results
|
||||||
|
Loading…
Reference in New Issue
Block a user