當前位置: 首頁>>代碼示例>>Golang>>正文


Golang MungeObject.Refresh方法代碼示例

本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.Refresh方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.Refresh方法的具體用法?Golang MungeObject.Refresh怎麽用?Golang MungeObject.Refresh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在k8s/io/contrib/mungegithub/github.MungeObject的用法示例。


在下文中一共展示了MungeObject.Refresh方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: doGithubE2EAndMerge

func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) {
	err := obj.Refresh()
	if err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown)
		return
	}

	if !sq.validForMerge(obj) {
		return
	}

	if obj.HasLabel(e2eNotRequiredLabel) {
		obj.MergePR("submit-queue")
		sq.SetMergeStatus(obj, merged)
		return
	}

	if err := obj.WriteComment(verifySafeToMergeBody); err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown)
		return
	}

	// Wait for the build to start
	sq.SetMergeStatus(obj, ghE2EWaitingStart)
	err = obj.WaitForPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
	if err != nil {
		s := fmt.Sprintf("Failed waiting for PR to start testing: %v", err)
		sq.SetMergeStatus(obj, s)
		return
	}

	// Wait for the status to go back to something other than pending
	sq.SetMergeStatus(obj, ghE2ERunning)
	err = obj.WaitForNotPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
	if err != nil {
		s := fmt.Sprintf("Failed waiting for PR to finish testing: %v", err)
		sq.SetMergeStatus(obj, s)
		return
	}

	// Check if the thing we care about is success
	if ok := obj.IsStatusSuccess([]string{sq.E2EStatusContext, sq.UnitStatusContext}); !ok {
		sq.SetMergeStatus(obj, ghE2EFailed)
		return
	}

	if !sq.e2eStable() {
		sq.SetMergeStatus(obj, e2eFailure)
		return
	}

	obj.MergePR("submit-queue")
	sq.updateMergeRate()
	sq.SetMergeStatus(obj, merged)
	return
}
開發者ID:timstclair,項目名稱:kube-contrib,代碼行數:58,代碼來源:submit-queue.go

示例2: doGithubE2EAndMerge

// Returns true if we can discard the PR from the queue, false if we must keep it for later.
func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) bool {
	interruptedObj := sq.interruptedObj
	sq.interruptedObj = nil

	err := obj.Refresh()
	if err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown)
		return true
	}

	if !sq.validForMerge(obj) {
		return true
	}

	if obj.HasLabel(retestNotRequiredLabel) || obj.HasLabel(retestNotRequiredDocsOnlyLabel) {
		atomic.AddInt32(&sq.instantMerges, 1)
		sq.mergePullRequest(obj)
		return true
	}

	if interruptedObj != nil {
		if interruptedObj.hasSHAChanged() {
			// This PR will have to be rested.
			// Make sure we don't have higher priority first.
			return false
		}
		glog.Infof("Skipping retest since head and base sha match previous attempt!")
		atomic.AddInt32(&sq.retestsAvoided, 1)
	} else if sq.retestPR(obj) {
		return true
	}

	if !sq.e2eStable(true) {
		if sq.validForMerge(obj) {
			sq.interruptedObj = newInterruptedObject(obj)
		}
		sq.SetMergeStatus(obj, e2eFailure)
		return true
	}

	sq.mergePullRequest(obj)
	return true
}
開發者ID:danielibrahim,項目名稱:contrib,代碼行數:45,代碼來源:submit-queue.go

示例3: doGithubE2EAndMerge

// Returns true if we can discard the PR from the queue, false if we must keep it for later.
func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) bool {
	interruptedObj := sq.interruptedObj
	sq.interruptedObj = nil

	err := obj.Refresh()
	if err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown)
		return true
	}

	if !sq.validForMerge(obj) {
		return true
	}

	if obj.HasLabel(retestNotRequiredLabel) || obj.HasLabel(retestNotRequiredDocsOnlyLabel) {
		atomic.AddInt32(&sq.instantMerges, 1)
		sq.mergePullRequest(obj)
		return true
	}

	sha, _, ok := obj.GetHeadAndBase()
	if !ok {
		glog.Errorf("%d: Unable to get SHA", *obj.Issue.Number)
		sq.SetMergeStatus(obj, unknown)
		return true
	}
	if interruptedObj != nil {
		if interruptedObj.hasSHAChanged() {
			// This PR will have to be rested.
			// Make sure we don't have higher priority first.
			return false
		}
		glog.Infof("Skipping retest since head and base sha match previous attempt!")
		atomic.AddInt32(&sq.retestsAvoided, 1)
	} else {
		if sq.retestPR(obj) {
			return true
		}

		err := obj.Refresh()
		if err != nil {
			glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
			sq.SetMergeStatus(obj, unknown)
			return true
		}
	}

	// We shouldn't merge if it's not valid anymore
	if !sq.validForMerge(obj) {
		glog.Errorf("%d: Not mergeable anymore. Do not merge.", *obj.Issue.Number)
		return true
	}

	if newSha, _, ok := obj.GetHeadAndBase(); !ok {
		glog.Errorf("%d: Unable to get SHA", *obj.Issue.Number)
		sq.SetMergeStatus(obj, unknown)
		return true
	} else if newSha != sha {
		glog.Errorf("%d: Changed while running the test. Do not merge.", *obj.Issue.Number)
		sq.SetMergeStatus(obj, headCommitChanged)
		return false
	}

	if !sq.e2eStable(true) {
		if sq.validForMerge(obj) {
			sq.interruptedObj = newInterruptedObject(obj)
		}
		sq.SetMergeStatus(obj, e2eFailure)
		return true
	}

	sq.mergePullRequest(obj)
	return true
}
開發者ID:Q-Lee,項目名稱:contrib,代碼行數:76,代碼來源:submit-queue.go

示例4: doGithubE2EAndMerge

// Returns true if we can discard the PR from the queue, false if we must keep it for later.
func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) bool {
	interruptedObj := sq.interruptedObj
	sq.interruptedObj = nil

	err := obj.Refresh()
	if err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown)
		return true
	}

	if !sq.validForMerge(obj) {
		return true
	}

	if obj.HasLabel(retestNotRequiredLabel) {
		sq.mergePullRequest(obj)
		return true
	}

	if interruptedObj != nil {
		if interruptedObj.hasSHAChanged() {
			// This PR will have to be rested.
			// Make sure we don't have higher priority first.
			return false
		}
		glog.Infof("Skipping retest since head and base sha match previous attempt!")
		atomic.AddInt32(&sq.retestsAvoided, 1)
	} else {
		if err := obj.WriteComment(retestBody); err != nil {
			glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
			sq.SetMergeStatus(obj, unknown)
			return true
		}

		// Wait for the retest to start
		sq.SetMergeStatus(obj, ghE2EWaitingStart)
		err = obj.WaitForPending(sq.RequiredRetestContexts)
		if err != nil {
			sq.SetMergeStatus(obj, fmt.Sprintf("Failed waiting for PR to start testing: %v", err))
			return true
		}

		// Wait for the status to go back to something other than pending
		sq.SetMergeStatus(obj, ghE2ERunning)
		err = obj.WaitForNotPending(sq.RequiredRetestContexts)
		if err != nil {
			sq.SetMergeStatus(obj, fmt.Sprintf("Failed waiting for PR to finish testing: %v", err))
			return true
		}

		// Check if the thing we care about is success
		if ok := obj.IsStatusSuccess(sq.RequiredRetestContexts); !ok {
			sq.SetMergeStatus(obj, ghE2EFailed)
			return true
		}
	}

	if !sq.e2eStable(true) {
		if sq.validForMerge(obj) {
			sq.interruptedObj = newInterruptedObject(obj)
		}
		sq.SetMergeStatus(obj, e2eFailure)
		return true
	}

	sq.mergePullRequest(obj)
	return true
}
開發者ID:raggi,項目名稱:contrib,代碼行數:70,代碼來源:submit-queue.go

示例5: doGithubE2EAndMerge

func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) {
	err := obj.Refresh()
	if err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown, true)
		return
	}

	if m, err := obj.IsMerged(); err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown, true)
		return
	} else if m {
		sq.SetMergeStatus(obj, merged, true)
		return
	}

	if mergeable, err := obj.IsMergeable(); err != nil {
		sq.SetMergeStatus(obj, undeterminedMergability, true)
		return
	} else if !mergeable {
		sq.SetMergeStatus(obj, unmergeable, true)
		return
	}

	if !sq.e2eStable() {
		sq.SetMergeStatus(obj, e2eFailure, true)
		return
	}

	if obj.HasLabel(e2eNotRequiredLabel) {
		obj.MergePR("submit-queue")
		sq.SetMergeStatus(obj, merged, true)
		return
	}

	body := "@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]"
	if err := obj.WriteComment(body); err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown, true)
		return
	}

	// Wait for the build to start
	sq.SetMergeStatus(obj, ghE2EWaitingStart, true)
	err = obj.WaitForPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
	if err != nil {
		s := fmt.Sprintf("Failed waiting for PR to start testing: %v", err)
		sq.SetMergeStatus(obj, s, true)
		return
	}

	// Wait for the status to go back to something other than pending
	sq.SetMergeStatus(obj, ghE2ERunning, true)
	err = obj.WaitForNotPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
	if err != nil {
		s := fmt.Sprintf("Failed waiting for PR to finish testing: %v", err)
		sq.SetMergeStatus(obj, s, true)
		return
	}

	// Check if the thing we care about is success
	if ok := obj.IsStatusSuccess([]string{sq.E2EStatusContext, sq.UnitStatusContext}); !ok {
		sq.SetMergeStatus(obj, ghE2EFailed, true)
		return
	}

	if !sq.e2eStable() {
		sq.SetMergeStatus(obj, e2eFailure, true)
		return
	}

	obj.MergePR("submit-queue")
	sq.SetMergeStatus(obj, merged, true)
	return
}
開發者ID:silasbw,項目名稱:contrib,代碼行數:76,代碼來源:submit-queue.go

示例6: doGithubE2EAndMerge

func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) {
	err := obj.Refresh()
	if err != nil {
		glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
		sq.SetMergeStatus(obj, unknown)
		return
	}

	if !sq.validForMerge(obj) {
		return
	}

	if obj.HasLabel(e2eNotRequiredLabel) {
		obj.MergePR("submit-queue")
		sq.SetMergeStatus(obj, merged)
		return
	}

	// See if we can skip the retest.
	headSHA, baseRef, gotHeadSHA := obj.GetHeadAndBase()
	baseSHA := ""
	gotBaseSHA := false
	if gotHeadSHA {
		baseSHA, gotBaseSHA = obj.GetSHAFromRef(baseRef)
	}
	maySkipTest := gotHeadSHA && gotBaseSHA &&
		sq.interruptedMergeBaseSHA == baseSHA &&
		sq.interruptedMergeHeadSHA == headSHA

	if maySkipTest {
		glog.Infof("Skipping retest since head and base sha match previous attempt!")
		atomic.AddInt32(&sq.retestsAvoided, 1)
	} else {
		if err := obj.WriteComment(verifySafeToMergeBody); err != nil {
			glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
			sq.SetMergeStatus(obj, unknown)
			return
		}

		// Wait for the build to start
		sq.SetMergeStatus(obj, ghE2EWaitingStart)
		err = obj.WaitForPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
		if err != nil {
			s := fmt.Sprintf("Failed waiting for PR to start testing: %v", err)
			sq.SetMergeStatus(obj, s)
			return
		}

		// re-get the base SHA in case something merged between us checking and
		// starting the tests.
		if gotHeadSHA {
			baseSHA, gotBaseSHA = obj.GetSHAFromRef(baseRef)
		}

		// Wait for the status to go back to something other than pending
		sq.SetMergeStatus(obj, ghE2ERunning)
		err = obj.WaitForNotPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
		if err != nil {
			s := fmt.Sprintf("Failed waiting for PR to finish testing: %v", err)
			sq.SetMergeStatus(obj, s)
			return
		}

		// Check if the thing we care about is success
		if ok := obj.IsStatusSuccess([]string{sq.E2EStatusContext, sq.UnitStatusContext}); !ok {
			sq.SetMergeStatus(obj, ghE2EFailed)
			return
		}
	}

	if !sq.e2eStable(true) {
		if gotHeadSHA && gotBaseSHA {
			sq.interruptedMergeBaseSHA = baseSHA
			sq.interruptedMergeHeadSHA = headSHA
		}
		sq.SetMergeStatus(obj, e2eFailure)
		return
	}

	obj.MergePR("submit-queue")
	sq.updateMergeRate()
	sq.SetMergeStatus(obj, merged)
	return
}
開發者ID:freehan,項目名稱:contrib,代碼行數:84,代碼來源:submit-queue.go


注:本文中的k8s/io/contrib/mungegithub/github.MungeObject.Refresh方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。