Indefero

Indefero Commit Details


Date:2009-07-03 03:23:49 (15 years 5 months ago)
Author:Loic d'Anterroches
Branch:develop, feature-issue_links, feature.better-home, feature.content-md5, feature.diff-whitespace, feature.download-md5, feature.issue-links, feature.issue-of-others, feature.issue-summary, feature.search-filter, feature.webrepos, feature.wiki-default-page, master, release-1.1, release-1.2, release-1.3
Commit:7d6cb222912cee5c7ac353efea7a55fc5a7b2d82
Parents: 32507085b40b2aa9cef30212f84dbeea1e830e22
Message:Fixed to have a better character encoding detection of the git log.

Changes:

File differences

src/IDF/Commit.php
189189
190190
191191
192
192193
193194
194195
......
196197
197198
198199
199
200
200201
201202
202203
*/
public static function toUTF8($text)
{
$enc = 'ASCII, UTF-8, ISO-8859-1, JIS, EUC-JP, SJIS';
$ref = $text;
if (is_array($text)) {
$ref = $text[0];
if (Pluf_Text_UTF8::check($ref)) {
return $text;
}
$encoding = mb_detect_encoding($ref, mb_detect_order(), true);
$encoding = mb_detect_encoding($ref, $enc, true);
if ($encoding == false) {
$encoding = Pluf_Text_UTF8::detect_cyr_charset($ref);
}
src/IDF/Scm/Git.php
402402
403403
404404
405
406405
407406
408
407
409408
410409
411410
412
413411
414412
415413
* Parse the log lines of a --pretty=medium log output.
*
* @param array Lines.
* @param int Number of lines in the headers (3)
* @return array Change log.
*/
public static function parseLog($lines, $hdrs=3)
public static function parseLog($lines)
{
$res = array();
$c = array();
$hdrs += 2;
$inheads = true;
$next_is_title = false;
foreach ($lines as $line) {
src/IDF/Tests/TestGit.php
4040
4141
4242
43
43
44
45
46
4447
45
46
47
48
49
48
49
50
51
52
53
54
55
56
57
58
59
5060
51
61
}
public function testGitCache()
/**
* parse a log encoded in iso 8859-1
*/
public function testParseIsoLog()
{
$repo = substr(dirname(__FILE__), 0, -strlen('src/IDF/Tests')).'/.git';
$repo = '/home/loa/Vendors/linux-git/.git';
$git = new IDF_Scm_Git($repo);
$git->buildBlobInfoCache();
//$git->getCachedBlobInfo(array());
$log_lines = preg_split("/\015\012|\015|\012/", file_get_contents(dirname(__FILE__).'/data/git-log-iso-8859-1.txt'));
$log = IDF_Scm_Git::parseLog($log_lines);
$titles = array(
'Quick Profiler entfernt',
'Anwendungsmenu Divider eingefügt',
'Anwendungen aufäumen'
);
foreach ($log as $change) {
$this->assertEqual(array_shift($titles),
IDF_Commit::toUTF8($change->title));
}
}
}
}
src/IDF/Tests/data/git-log-iso-8859-1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Fri Jul 3 01:44:11 2009 +0200
Quick Profiler entfernt
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Wed Jul 1 15:51:22 2009 +0200
commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
Author: unknown <a@(none)>
Date: Wed Jul 1 15:05:41 2009 +0200

Archive Download the corresponding diff file

Page rendered in 0.18281s using 13 queries.