本文整理匯總了Golang中github.com/google/git-appraise/repository.Repo.GetCommitDetails方法的典型用法代碼示例。如果您正苦於以下問題:Golang Repo.GetCommitDetails方法的具體用法?Golang Repo.GetCommitDetails怎麽用?Golang Repo.GetCommitDetails使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/google/git-appraise/repository.Repo
的用法示例。
在下文中一共展示了Repo.GetCommitDetails方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createDifferentialDiff
// createDifferentialDiff generates a Phabricator resource that represents a diff between two revisions.
//
// The generated resource includes metadata about how the diff was generated, and a JSON representation
// of the changes from the diff, as parsed by Phabricator.
func (arc Arcanist) createDifferentialDiff(repo repository.Repo, mergeBase, revision string, req request.Request, priorDiffs []string) (*differentialDiff, error) {
repoCommitDetails, err := repo.GetCommitDetails(revision)
if err != nil {
return nil, err
}
var revisionDetails CommitDetails
revisionDetails.Commit = revision
revisionDetails.Author = repoCommitDetails.Author
revisionDetails.AuthorEmail = repoCommitDetails.AuthorEmail
revisionDetails.Tree = repoCommitDetails.Tree
revisionDetails.Time = repoCommitDetails.Time
revisionDetails.Parents = repoCommitDetails.Parents
revisionDetails.Summary = repoCommitDetails.Summary
changes, err := arc.getDiffChanges(repo, mergeBase, revision)
if err != nil {
return nil, err
}
createRequest := differentialCreateDiffRequest{
Branch: abbreviateRefName(req.ReviewRef),
SourceControlSystem: "git",
SourceControlBaseRevision: string(mergeBase),
SourcePath: repo.GetPath(),
LintStatus: "skip",
UnitStatus: "skip",
Changes: changes,
}
var createResponse differentialCreateDiffResponse
runArcCommandOrDie("differential.creatediff", createRequest, &createResponse)
if createResponse.Error != "" {
return nil, fmt.Errorf(createResponse.ErrorMessage)
}
localCommits := make(map[string]interface{})
for _, priorDiff := range priorDiffs {
diffID, err := strconv.Atoi(priorDiff)
if err != nil {
return nil, err
}
queryRequest := differentialQueryDiffsRequest{[]int{diffID}}
var queryResponse differentialQueryDiffsResponse
runArcCommandOrDie("differential.querydiffs", queryRequest, &queryResponse)
if queryResponse.Error != "" {
return nil, fmt.Errorf(queryResponse.ErrorMessage)
}
priorProperty := queryResponse.Response[priorDiff].Properties
if priorPropertyMap, ok := priorProperty.(map[string]interface{}); ok {
if localCommitsProperty, ok := priorPropertyMap["local:commits"]; ok {
if priorLocalCommits, ok := localCommitsProperty.(map[string]interface{}); ok {
for id, val := range priorLocalCommits {
localCommits[id] = val
}
}
}
}
}
localCommits[string(revision)] = revisionDetails
localCommitsProperty, err := json.Marshal(localCommits)
if err != nil {
return nil, err
}
if err := arc.setDiffProperty(createResponse.Response.ID, "local:commits", string(localCommitsProperty)); err != nil {
return nil, err
}
return &createResponse.Response, nil
}