func findLastCommit(commitsMap map[string]interface{}) string {
	var timestamps []int
	timestampCommitMap := make(map[int]string)
	for commit, commitData := range commitsMap {
		commitProperties, ok := commitData.(map[string]interface{})
		if ok {
			timestampString, ok := commitProperties["time"].(string)
			if ok {
				timestamp, err := strconv.Atoi(timestampString)
				if err != nil {
					log.Fatal(err)
				}
				timestamps = append(timestamps, timestamp)
				timestampCommitMap[timestamp] = commit
			}
		}
	}
	if len(timestamps) == 0 {
		return ""
	}
	sort.Sort(sort.Reverse(sort.IntSlice(timestamps)))
	return timestampCommitMap[timestamps[0]]
}
Differential does not actually store the commit hash for the right hand side of a diff.
As such, if we have to do some deep inspection to find it. What Differential *does*
store is a map of "local commits". The last such local commit (by timestamp) is the
one that was actually used to generate the right hand side of the diff.
package arcanist
import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/google/git-appraise/repository"
	"github.com/google/git-appraise/review/request"
	"log"
	"sort"
	"strconv"
)
type differentialCreateRawDiffRequest struct {
	Diff string `json:"diff"`
}
type rawDiff struct {
	ID int `json:"id"`
}
type differentialCreateRawDiffResponse struct {
	Error        string  `json:"error,omitempty"`
	ErrorMessage string  `json:"errorMessage,omitempty"`
	Response     rawDiff `json:"response,omitempty"`
}
type differentialQueryDiffsRequest struct {
	IDs []int `json:"ids"`
}
type queryDiffItem struct {
	ID         string        `json:"id"`
	Changes    []interface{} `json:"changes"`
	Properties interface{}   `json:"properties"`
}
type differentialQueryDiffsResponse struct {
	Error        string                   `json:"error,omitempty"`
	ErrorMessage string                   `json:"errorMessage,omitempty"`
	Response     map[string]queryDiffItem `json:"response"`
}
func readDiff(diffID int) (*queryDiffItem, error) {
	queryRequest := differentialQueryDiffsRequest{IDs: []int{diffID}}
	var queryResponse differentialQueryDiffsResponse
	runArcCommandOrDie("differential.querydiffs", queryRequest, &queryResponse)
	if queryResponse.Error != "" {
		return nil, fmt.Errorf(queryResponse.ErrorMessage)
	}
	if diff, ok := queryResponse.Response[strconv.Itoa(diffID)]; ok {
		return &diff, nil
	}
	return nil, nil
}