code: func ParseBuildSet(buildSet string) proto.Message {
  	// fmt.Sscanf cannot be used for this parsing because
  	//   var a, b string
  	//   fmt.Scanf("a/b", "%s/%s", &a, &b)
  	//   a == "a/b", b == ""
  
  	p := strings.Split(buildSet, "/")
  	for _, c := range p {
  		if c == "" {
  			return nil
  		}
  	}
  	n := len(p)
  	switch {
  	case n == 5 && p[0] == "patch" && p[1] == "gerrit":
  		gerrit := &pb.GerritChange{
  			Host: p[2],
  		}
  		var err error
  		if gerrit.Change, err = strconv.ParseInt(p[3], 10, 64); err != nil {
  			return nil
  		}
  		if gerrit.Patchset, err = strconv.ParseInt(p[4], 10, 64); err != nil {
  			return nil
  		}
  		return gerrit
  
  	case n >= 5 && p[0] == "commit" && p[1] == "gitiles":
  		if p[n-2] != "+" || !looksLikeSha1(p[n-1]) {
  			return nil
  		}
  		return &pb.GitilesCommit{
  			Host:    p[2],
  			Project: strings.Join(p[3:n-2], "/"), // exclude plus
  			Id:      p[n-1],
  		}
  
  	default:
  		return nil
  	}
  }
docs: // ParseBuildSet tries to parse buildset as one of the known formats.
  // May return *pb.GerritChange, *pb.GitilesCommit
  // or nil.