本文整理匯總了Golang中github.com/google/git-phabricator-mirror/mirror/repository.Repo.GetNotes方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repo.GetNotes方法的具體用法?Golang Repo.GetNotes怎麽用?Golang Repo.GetNotes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/git-phabricator-mirror/mirror/repository.Repo
的用法示例。
在下文中一共展示了Repo.GetNotes方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: mirrorCommentsIntoReview
func (arc Arcanist) mirrorCommentsIntoReview(repo repository.Repo, review differentialReview, comments comment.CommentMap) {
existingComments := review.LoadComments()
newComments := comments.FilterOverlapping(existingComments)
var lastCommitForLastDiff string
var latestDiffForReview int
commitToDiffMap := make(map[string]string)
for _, diffIDString := range review.Diffs {
lastCommit := findCommitForDiff(diffIDString)
commitToDiffMap[lastCommit] = diffIDString
diffID, err := strconv.Atoi(diffIDString)
if err == nil && diffID > latestDiffForReview {
lastCommitForLastDiff = lastCommit
latestDiffForReview = diffID
}
}
report := ci.GetLatestCIReport(repo.GetNotes(ci.Ref, repository.Revision(lastCommitForLastDiff)))
log.Printf("The latest CI report for diff %d is %+v ", latestDiffForReview, report)
if report.URL != "" {
unitDiffProperty := differentialUnitDiffProperty{
Name: report.Agent,
Link: report.URL,
Result: translateReportStatusToDifferentialUnitResult(report.Status),
}
// Note that although the unit tests property is a JSON object, Phabricator
// expects there to be a list of such objects for any given diff. Therefore
// we wrap the object in a list before marshaling it to send to the server.
// TODO(ojarjur): We should take advantage of the fact that this is a list,
// and include the latest CI report for each agent. That would allow us to
// display results from multiple test runners in a code review.
propertyBytes, err := json.Marshal([]differentialUnitDiffProperty{unitDiffProperty})
if err == nil {
err = arc.setDiffProperty(latestDiffForReview, unitDiffPropertyName, string(propertyBytes))
}
if err != nil {
log.Fatal(err.Error())
}
}
inlineRequests, commentRequests := review.buildCommentRequests(newComments, commitToDiffMap)
for _, request := range inlineRequests {
var response createInlineResponse
runArcCommandOrDie("differential.createinline", request, &response)
if response.Error != "" {
log.Println(response.ErrorMessage)
}
}
for _, request := range commentRequests {
var response createCommentResponse
runArcCommandOrDie("differential.createcomment", request, &response)
if response.Error != "" {
log.Println(response.ErrorMessage)
}
}
}
示例2: mirrorCommentsIntoReview
func (arc Arcanist) mirrorCommentsIntoReview(repo repository.Repo, review differentialReview, comments comment.CommentMap) {
existingComments := review.LoadComments()
newComments := comments.FilterOverlapping(existingComments)
var lastCommitForLastDiff string
var latestDiffForReview string
commitToDiffMap := make(map[string]string)
for _, diffIDString := range review.Diffs {
lastCommit := findCommitForDiff(diffIDString)
commitToDiffMap[lastCommit] = diffIDString
if diffIDString > latestDiffForReview {
lastCommitForLastDiff = lastCommit
latestDiffForReview = diffIDString
}
}
report := ci.GetLatestCIReport(repo.GetNotes(ci.Ref, repository.Revision(lastCommitForLastDiff)))
log.Printf("The latest CI report for diff %s is %+v ", latestDiffForReview, report)
if report.URL != "" {
updateUnitResultsRequest := differentialUpdateUnitResultsRequest{
DiffID: latestDiffForReview,
Result: report.Status,
Link: report.URL,
//TODO(ckerur): Link does not work for some reason. Remove putting URL in Message once it does
Message: report.URL,
}
var unitResultsResponse differentialUpdateUnitResultsResponse
runArcCommandOrDie("differential.updateunitresults", updateUnitResultsRequest, &unitResultsResponse)
if unitResultsResponse.Error != "" {
log.Fatal(unitResultsResponse.ErrorMessage)
}
}
inlineRequests, commentRequests := review.buildCommentRequests(newComments, commitToDiffMap)
for _, request := range inlineRequests {
var response createInlineResponse
runArcCommandOrDie("differential.createinline", request, &response)
if response.Error != "" {
log.Println(response.ErrorMessage)
}
}
for _, request := range commentRequests {
var response createCommentResponse
runArcCommandOrDie("differential.createcomment", request, &response)
if response.Error != "" {
log.Println(response.ErrorMessage)
}
}
}
示例3: mirrorRepoToReview
func mirrorRepoToReview(repo repository.Repo, tool review.Tool, syncToRemote bool) {
if syncToRemote {
if err := repo.PullUpdates(); err != nil {
log.Printf("Failed to pull updates for the repo %v: %v\n", repo, err)
return
}
}
stateHash := repo.GetRepoStateHash()
if processedStates[repo.GetPath()] != stateHash {
log.Print("Mirroring repo: ", repo)
for _, revision := range repo.ListNotedRevisions(request.Ref) {
existingComments[revision] = comment.ParseAllValid(repo.GetNotes(comment.Ref, revision))
for _, req := range request.ParseAllValid(repo.GetNotes(request.Ref, revision)) {
tool.EnsureRequestExists(repo, revision, req, existingComments[revision])
}
}
openReviews[repo.GetPath()] = tool.ListOpenReviews(repo)
processedStates[repo.GetPath()] = stateHash
tool.Refresh(repo)
}
for _, review := range openReviews[repo.GetPath()] {
if reviewCommit := review.GetFirstCommit(repo); reviewCommit != nil {
log.Println("Processing review: ", *reviewCommit)
revisionComments := getExistingComments(*reviewCommit)
log.Printf("Loaded %d comments for %v\n", len(revisionComments), *reviewCommit)
for _, c := range review.LoadComments() {
if !hasOverlap(c, revisionComments) {
// The comment is new.
note, err := c.Write()
if err != nil {
log.Fatal(err)
}
log.Printf("Appending a comment: %s", string(note))
repo.AppendNote(comment.Ref, *reviewCommit, note, c.Author)
} else {
log.Printf("Skipping '%v', as it has already been written\n", c)
}
}
}
}
if syncToRemote {
if err := repo.PushUpdates(); err != nil {
log.Printf("Failed to push updates to the repo %v: %v\n", repo, err)
}
}
}