Add issue updating from commit messages in new pull request
This commit is contained in:
parent
abd1f1f6e1
commit
8a9bd7a9b7
|
|
@ -763,6 +763,33 @@ func MergePullRequestAction(actUser *User, repo *Repository, pull *Issue, commit
|
||||||
return mergePullRequestAction(x, actUser, repo, pull, commits)
|
return mergePullRequestAction(x, actUser, repo, pull, commits)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newPullRequestAction(e Engine, doer *User, repo *Repository, pull *Issue, commits *PushCommits) (err error) {
|
||||||
|
if err = NotifyWatchers(&Action{
|
||||||
|
ActUserID: doer.ID,
|
||||||
|
ActUser: doer,
|
||||||
|
OpType: ActionCreatePullRequest,
|
||||||
|
Content: fmt.Sprintf("%d|%s", pull.Index, pull.Title),
|
||||||
|
RepoID: repo.ID,
|
||||||
|
Repo: repo,
|
||||||
|
IsPrivate: repo.IsPrivate,
|
||||||
|
}); err != nil {
|
||||||
|
log.Error(4, "NotifyWatchers: %v", err)
|
||||||
|
} else if err = pull.MailParticipants(); err != nil {
|
||||||
|
log.Error(4, "MailParticipants: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPullRequestAction adds new action for merging pull request.
|
||||||
|
func NewPullRequestAction(actUser *User, repo *Repository, pull *Issue, commits *PushCommits) error {
|
||||||
|
if err := UpdateIssuesCommit(actUser, repo, commits.Commits, false); err != nil {
|
||||||
|
log.Error(4, "updateIssuesCommit: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return newPullRequestAction(x, actUser, repo, pull, commits)
|
||||||
|
}
|
||||||
|
|
||||||
// GetFeedsOptions options for retrieving feeds
|
// GetFeedsOptions options for retrieving feeds
|
||||||
type GetFeedsOptions struct {
|
type GetFeedsOptions struct {
|
||||||
RequestedUser *User
|
RequestedUser *User
|
||||||
|
|
|
||||||
|
|
@ -772,23 +772,45 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
|
||||||
|
|
||||||
UpdateIssueIndexer(pull.ID)
|
UpdateIssueIndexer(pull.ID)
|
||||||
|
|
||||||
if err = NotifyWatchers(&Action{
|
|
||||||
ActUserID: pull.Poster.ID,
|
|
||||||
ActUser: pull.Poster,
|
|
||||||
OpType: ActionCreatePullRequest,
|
|
||||||
Content: fmt.Sprintf("%d|%s", pull.Index, pull.Title),
|
|
||||||
RepoID: repo.ID,
|
|
||||||
Repo: repo,
|
|
||||||
IsPrivate: repo.IsPrivate,
|
|
||||||
}); err != nil {
|
|
||||||
log.Error(4, "NotifyWatchers: %v", err)
|
|
||||||
} else if err = pull.MailParticipants(); err != nil {
|
|
||||||
log.Error(4, "MailParticipants: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
pr.Issue = pull
|
pr.Issue = pull
|
||||||
pull.PullRequest = pr
|
pull.PullRequest = pr
|
||||||
mode, _ := AccessLevel(pull.Poster.ID, repo)
|
mode, _ := AccessLevel(pull.Poster.ID, repo)
|
||||||
|
|
||||||
|
var (
|
||||||
|
baseBranch *Branch
|
||||||
|
headBranch *Branch
|
||||||
|
baseCommit *git.Commit
|
||||||
|
headCommit *git.Commit
|
||||||
|
baseGitRepo *git.Repository
|
||||||
|
)
|
||||||
|
if baseBranch, err = pr.BaseRepo.GetBranch(pr.BaseBranch); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if baseCommit, err = baseBranch.GetCommit(); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if headBranch, err = pr.HeadRepo.GetBranch(pr.HeadBranch); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if headCommit, err = headBranch.GetCommit(); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if baseGitRepo, err = git.OpenRepository(pr.BaseRepo.RepoPath()); err != nil {
|
||||||
|
log.Error(4, "OpenRepository", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
l, err := baseGitRepo.CommitsBetweenIDs(headCommit.ID.String(), baseCommit.ID.String())
|
||||||
|
if err != nil {
|
||||||
|
log.Error(4, "CommitsBetweenIDs: %v", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
commits := ListToPushCommits(l)
|
||||||
|
if err = NewPullRequestAction(pull.Poster, repo, pull, commits); err != nil {
|
||||||
|
log.Error(4, "NewPullRequestAction [%d]: %v", pr.ID, err)
|
||||||
|
}
|
||||||
|
|
||||||
if err = PrepareWebhooks(repo, HookEventPullRequest, &api.PullRequestPayload{
|
if err = PrepareWebhooks(repo, HookEventPullRequest, &api.PullRequestPayload{
|
||||||
Action: api.HookIssueOpened,
|
Action: api.HookIssueOpened,
|
||||||
Index: pull.Index,
|
Index: pull.Index,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user