| 161 | } |
| 162 | |
| 163 | func (comment Comment) serialize() ([]byte, error) { |
| 164 | if len(comment.Timestamp) < 10 { |
| 165 | // To make sure that timestamps from before 2001 appear in the correct |
| 166 | // alphabetical order, we reformat the timestamp to be at least 10 characters |
| 167 | // and zero-padded. |
| 168 | time, err := strconv.ParseInt(comment.Timestamp, 10, 64) |
| 169 | if err == nil { |
| 170 | comment.Timestamp = fmt.Sprintf("%010d", time) |
| 171 | } |
| 172 | // We ignore the other case, as the comment timestamp is not in a format |
| 173 | // we expected, so we should just leave it alone. |
| 174 | } |
| 175 | return json.Marshal(comment) |
| 176 | } |
| 177 | |
| 178 | // Write writes a review comment as a JSON-formatted git note. |
| 179 | func (comment Comment) Write() (repository.Note, error) { |