function writeComments(GBExposedContent $obj)
{
if (!$obj->comments) {
return;
}
# sort
ksort($obj->comments);
# init comments db
$cdb = $obj->getCommentsDB();
$cdb->autocommitToRepo = false;
$cdb->begin(true);
try {
foreach ($obj->comments as $comment) {
$cdb->append($comment);
}
} catch (Exception $e) {
$cdb->rollback();
throw $e;
}
$cdb->commit();
git::add($cdb->file);
}