public function testRemovesComments() { $text = <<<___TEXT These are lines of text # this is a comment # and another one. And more text ___TEXT; $expected = "These are lines of text\nAnd more text"; $this->assertSame($expected, \ElggCommitMessage::removeComments($text)); }
$is_file = false; if ($argc === 2) { // check file or msg itself $arg = $argv[1]; if (file_exists($arg)) { $is_file = true; $msg_tmp = file_get_contents($arg); } else { $msg_tmp = $arg; } } else { // check for std in $msg_tmp = file_get_contents("php://stdin"); } require_once 'ElggCommitMessage.php'; $msg = new ElggCommitMessage($msg_tmp); if (!$msg->getMsg()) { usage(); } if ($msg->shouldIgnore()) { output("Ignoring commit.", 'notice'); exit(0); } // basic format // don't continue if not correct if (!$msg->isValidFormat()) { output("Fail.", 'error'); output("Not in the format `type(component): summary`", 'error'); output($msg, 'error'); if ($is_file) { output("\nCommit message saved in " . $argv[1]);