Change Details
| src/IDF/Commit.php |
| 189 | 189 | */ |
| 190 | 190 | public static function toUTF8($text) |
| 191 | 191 | { |
| 192 | $enc = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS'; |
| 192 | 193 | $ref = $text; |
| 193 | 194 | if (is_array($text)) { |
| 194 | 195 | $ref = $text[0]; |
| ... | ... | |
| 196 | 197 | if (Pluf_Text_UTF8::check($ref)) { |
| 197 | 198 | return $text; |
| 198 | 199 | } |
| 199 | | $encoding = mb_detect_encoding($ref, mb_detect_order(), true); |
| 200 | $encoding = mb_detect_encoding($ref, $enc, true); |
| 200 | 201 | if ($encoding == false) { |
| 201 | 202 | $encoding = Pluf_Text_UTF8::detect_cyr_charset($ref); |
| 202 | 203 | } |
| src/IDF/Scm/Git.php |
| 402 | 402 | * Parse the log lines of a --pretty=medium log output. |
| 403 | 403 | * |
| 404 | 404 | * @param array Lines. |
| 405 | | * @param int Number of lines in the headers (3) |
| 406 | 405 | * @return array Change log. |
| 407 | 406 | */ |
| 408 | | public static function parseLog($lines, $hdrs=3) |
| 407 | public static function parseLog($lines) |
| 409 | 408 | { |
| 410 | 409 | $res = array(); |
| 411 | 410 | $c = array(); |
| 412 | | $hdrs += 2; |
| 413 | 411 | $inheads = true; |
| 414 | 412 | $next_is_title = false; |
| 415 | 413 | foreach ($lines as $line) { |
| src/IDF/Tests/TestGit.php |
| 40 | 40 | |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | | public function testGitCache() |
| 43 | /** |
| 44 | * parse a log encoded in iso 8859-1 |
| 45 | */ |
| 46 | public function testParseIsoLog() |
| 44 | 47 | { |
| 45 | | $repo = substr(dirname(__FILE__), 0, -strlen('src/IDF/Tests')).'/.git'; |
| 46 | | $repo = '/home/loa/Vendors/linux-git/.git'; |
| 47 | | $git = new IDF_Scm_Git($repo); |
| 48 | | $git->buildBlobInfoCache(); |
| 49 | | //$git->getCachedBlobInfo(array()); |
| 48 | $log_lines = preg_split("/\015\012|\015|\012/", file_get_contents(dirname(__FILE__).'/data/git-log-iso-8859-1.txt')); |
| 49 | $log = IDF_Scm_Git::parseLog($log_lines); |
| 50 | $titles = array( |
| 51 | 'Quick Profiler entfernt', |
| 52 | 'Anwendungsmenu Divider eingefügt', |
| 53 | 'Anwendungen aufäumen' |
| 54 | ); |
| 55 | foreach ($log as $change) { |
| 56 | $this->assertEqual(array_shift($titles), |
| 57 | IDF_Commit::toUTF8($change->title)); |
| 58 | } |
| 59 | |
| 50 | 60 | } |
| 51 | | } |
| 61 | } |
| src/IDF/Tests/data/git-log-iso-8859-1.txt |
| 1 | commit 11531a9dbc64a65150f2f38fbea7cef9d478a123 |
| 2 | Author: unknown <a@(none)> |
| 3 | Date: Fri Jul 3 01:44:11 2009 +0200 |
| 4 | |
| 5 | Quick Profiler entfernt |
| 6 | |
| 7 | commit 11531a9dbc64a65150f2f38fbea7cef9d478a123 |
| 8 | Author: unknown <a@(none)> |
| 9 | Date: Wed Jul 1 15:51:22 2009 +0200 |
| 10 | |
| 11 | Anwendungsmenu Divider eingefügt |
| 12 | |
| 13 | commit 11531a9dbc64a65150f2f38fbea7cef9d478a123 |
| 14 | Author: unknown <a@(none)> |
| 15 | Date: Wed Jul 1 15:05:41 2009 +0200 |
| 16 | |
| 17 | Anwendungen aufäumen |
| 18 | |
| 19 | |
Download the corresponding diff file