예제 #1
0
// Munge is the workhorse the will actually make updates to the PR
func (a *AssignFixesMunger) Munge(obj *github.MungeObject) {
	if !obj.IsPR() {
		return
	}
	// we need the PR for the "User" (creator of the PR not the assignee)
	pr, err := obj.GetPR()
	if err != nil {
		glog.Infof("Couldn't get PR %v", obj.Issue.Number)
		return
	}
	prOwner := github.DescribeUser(pr.User)

	issuesFixed := obj.GetPRFixesList()
	if issuesFixed == nil {
		return
	}
	for _, fixesNum := range issuesFixed {
		// "issue" is the issue referenced by the "fixes #<num>"
		issueObj, err := a.config.GetObject(fixesNum)
		if err != nil {
			glog.Infof("Couldn't get issue %v", fixesNum)
			continue
		}
		issue := issueObj.Issue
		if !a.AssignfixesReassign && issue.Assignee != nil {
			glog.V(6).Infof("skipping %v: reassign: %v assignee: %v", *issue.Number, a.AssignfixesReassign, github.DescribeUser(issue.Assignee))
			continue
		}
		glog.Infof("Assigning %v to %v (previously assigned to %v)", *issue.Number, prOwner, github.DescribeUser(issue.Assignee))
		// although it says "AssignPR" it's more generic than that and is really just an issue.
		issueObj.AssignPR(prOwner)
	}

}