本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.GetCommits方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.GetCommits方法的具體用法?Golang MungeObject.GetCommits怎麽用?Golang MungeObject.GetCommits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.GetCommits方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Munge
// Munge is the workhorse the will actually make updates to the PR
func (b *BlockPath) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if obj.HasLabel(doNotMergeLabel) {
return
}
commits, err := obj.GetCommits()
if err != nil {
return
}
for _, c := range commits {
for _, f := range c.Files {
if matchesAny(*f.Filename, b.blockRegexp) {
if matchesAny(*f.Filename, b.doNotBlockRegexp) {
continue
}
obj.WriteComment(blockPathBody)
obj.AddLabels([]string{doNotMergeLabel})
return
}
}
}
}
示例2: Munge
// Munge is the workhorse the will actually make updates to the PR
func (p *PathLabelMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
commits, err := obj.GetCommits()
if err != nil {
return
}
needsLabels := sets.NewString()
for _, c := range commits {
for _, f := range c.Files {
for _, lm := range p.labelMap {
if lm.regexp.MatchString(*f.Filename) {
if !obj.HasLabel(lm.label) {
needsLabels.Insert(lm.label)
}
}
}
}
}
if needsLabels.Len() != 0 {
obj.AddLabels(needsLabels.List())
}
}
示例3: Munge
// Munge is the workhorse the will actually make updates to the PR
func (b *BlockPath) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if obj.HasLabel(doNotMergeLabel) {
return
}
commits, err := obj.GetCommits()
if err != nil {
return
}
for _, c := range commits {
for _, f := range c.Files {
if matchesAny(*f.Filename, b.blockRegexp) {
if matchesAny(*f.Filename, b.doNotBlockRegexp) {
continue
}
body := fmt.Sprintf(`Adding label:%s because PR changes docs prohibited to auto merge
See http://kubernetes.io/editdocs/ for information about editing docs`, doNotMergeLabel)
obj.WriteComment(body)
obj.AddLabels([]string{doNotMergeLabel})
return
}
}
}
}
示例4: Munge
// Munge is the workhorse the will actually make updates to the PR
func (p *PathLabelMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
commits, err := obj.GetCommits()
if err != nil {
return
}
labelMap := *p.labelMap
needsLabels := sets.NewString()
for _, c := range commits {
for _, f := range c.Files {
for prefix, label := range labelMap {
if strings.HasPrefix(*f.Filename, prefix) && !obj.HasLabel(label) {
needsLabels.Insert(label)
}
}
}
}
if needsLabels.Len() != 0 {
obj.AddLabels(needsLabels.List())
}
}
示例5: foundByAllCommits
// Check that the commit messages for all commits in the PR are on the branch
func (c *ClearPickAfterMerge) foundByAllCommits(obj *github.MungeObject, branch string) bool {
commits, err := obj.GetCommits()
if err != nil {
glog.Infof("unable to get commits")
return false
}
for _, commit := range commits {
if commit.Commit == nil {
return false
}
if commit.Commit.Message == nil {
return false
}
found, _ := c.foundLog(branch, *commit.Commit.Message)
if !found {
return false
}
}
return true
}
示例6: Munge
// Munge is the workhorse the will actually make updates to the PR
func (p *PathLabelMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
commits, err := obj.GetCommits()
if err != nil {
return
}
needsLabels := sets.NewString()
for _, c := range commits {
for _, f := range c.Files {
for _, lm := range p.labelMap {
if lm.regexp.MatchString(*f.Filename) {
needsLabels.Insert(lm.label)
}
}
}
}
// This is all labels on the issue that the path munger controls
hasLabels := obj.LabelSet().Intersection(p.allLabels)
missingLabels := needsLabels.Difference(hasLabels)
if missingLabels.Len() != 0 {
obj.AddLabels(needsLabels.List())
}
extraLabels := hasLabels.Difference(needsLabels)
for _, label := range extraLabels.List() {
creator := obj.LabelCreator(label)
if creator == botName {
obj.RemoveLabel(label)
}
}
}
示例7: Munge
// Munge is the workhorse the will actually make updates to the PR
func (s *SizeMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
issue := obj.Issue
pr, err := obj.GetPR()
if err != nil {
return
}
s.getGeneratedFiles(obj)
genFiles := *s.genFiles
genPrefixes := *s.genPrefixes
if pr.Additions == nil {
glog.Warningf("PR %d has nil Additions", *pr.Number)
return
}
adds := *pr.Additions
if pr.Deletions == nil {
glog.Warningf("PR %d has nil Deletions", *pr.Number)
return
}
dels := *pr.Deletions
commits, err := obj.GetCommits()
if err != nil {
return
}
for _, c := range commits {
for _, f := range c.Files {
for _, p := range genPrefixes {
if strings.HasPrefix(*f.Filename, p) {
adds = adds - *f.Additions
dels = dels - *f.Deletions
continue
}
}
if genFiles.Has(*f.Filename) {
adds = adds - *f.Additions
dels = dels - *f.Deletions
continue
}
}
}
newSize := calculateSize(adds, dels)
newLabel := labelSizePrefix + newSize
existing := github.GetLabelsWithPrefix(issue.Labels, labelSizePrefix)
needsUpdate := true
for _, l := range existing {
if l == newLabel {
needsUpdate = false
continue
}
obj.RemoveLabel(l)
}
if needsUpdate {
obj.AddLabels([]string{newLabel})
body := fmt.Sprintf("Labelling this PR as %s", newLabel)
obj.WriteComment(body)
}
}
示例8: Munge
// Munge is the workhorse the will actually make updates to the PR
func (b *BlunderbussMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
issue := obj.Issue
if !b.blunderbussReassign && issue.Assignee != nil {
glog.V(6).Infof("skipping %v: reassign: %v assignee: %v", *issue.Number, b.blunderbussReassign, describeUser(issue.Assignee))
return
}
commits, err := obj.GetCommits()
if err != nil {
return
}
potentialOwners := weightMap{}
weightSum := int64(0)
for _, commit := range commits {
for _, file := range commit.Files {
fileWeight := int64(1)
if file.Changes != nil && *file.Changes != 0 {
fileWeight = int64(*file.Changes)
}
// Judge file size on a log scale-- effectively this
// makes three buckets, we shouldn't have many 10k+
// line changes.
fileWeight = int64(math.Log10(float64(fileWeight))) + 1
fileOwners := b.features.Repos.LeafAssignees(*file.Filename)
if fileOwners.Len() == 0 {
glog.Warningf("Couldn't find an owner for: %s", *file.Filename)
}
for _, owner := range fileOwners.List() {
if owner == *issue.User.Login {
continue
}
potentialOwners[owner] = potentialOwners[owner] + fileWeight
weightSum += fileWeight
}
}
}
if len(potentialOwners) == 0 {
glog.Errorf("No owners found for PR %d", *issue.Number)
return
}
printChance(potentialOwners, weightSum)
if issue.Assignee != nil {
cur := *issue.Assignee.Login
c := chance(potentialOwners[cur], weightSum)
glog.Infof("Current assignee %v has a %02.2f%% chance of having been chosen", cur, c)
}
selection := rand.Int63n(weightSum)
owner := ""
for o, w := range potentialOwners {
owner = o
selection -= w
if selection <= 0 {
break
}
}
c := chance(potentialOwners[owner], weightSum)
glog.Infof("Assigning %v to %v who had a %02.2f%% chance to be assigned (previously assigned to %v)", *issue.Number, owner, c, describeUser(issue.Assignee))
obj.AssignPR(owner)
}