diff --git a/src/IDF/Commit.php b/src/IDF/Commit.php
index 964b4ec..50c9402 100644
--- a/src/IDF/Commit.php
+++ b/src/IDF/Commit.php
@@ -189,6 +189,7 @@ class IDF_Commit extends Pluf_Model
*/
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];
@@ -196,7 +197,7 @@ class IDF_Commit extends Pluf_Model
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);
}
diff --git a/src/IDF/Scm/Git.php b/src/IDF/Scm/Git.php
index f684e3f..acb57ed 100644
--- a/src/IDF/Scm/Git.php
+++ b/src/IDF/Scm/Git.php
@@ -402,14 +402,12 @@ class IDF_Scm_Git extends IDF_Scm
* 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) {
diff --git a/src/IDF/Tests/TestGit.php b/src/IDF/Tests/TestGit.php
index cb4c992..9baf254 100644
--- a/src/IDF/Tests/TestGit.php
+++ b/src/IDF/Tests/TestGit.php
@@ -40,12 +40,22 @@ class IDF_Tests_TestGit extends UnitTestCase
}
- 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));
+ }
+
}
-}
\ No newline at end of file
+}
diff --git a/src/IDF/Tests/data/git-log-iso-8859-1.txt b/src/IDF/Tests/data/git-log-iso-8859-1.txt
new file mode 100644
index 0000000..c42a5ef
--- /dev/null
+++ b/src/IDF/Tests/data/git-log-iso-8859-1.txt
@@ -0,0 +1,19 @@
+commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
+Author: unknown
+Date: Fri Jul 3 01:44:11 2009 +0200
+
+ Quick Profiler entfernt
+
+commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
+Author: unknown
+Date: Wed Jul 1 15:51:22 2009 +0200
+
+ Anwendungsmenu Divider eingefügt
+
+commit 11531a9dbc64a65150f2f38fbea7cef9d478a123
+Author: unknown
+Date: Wed Jul 1 15:05:41 2009 +0200
+
+ Anwendungen aufäumen
+
+