diff --git a/perceval/backends/core/git.py b/perceval/backends/core/git.py index 2d00f7f0c..3b962353a 100644 --- a/perceval/backends/core/git.py +++ b/perceval/backends/core/git.py @@ -71,7 +71,7 @@ class Git(Backend): :raises RepositoryError: raised when there was an error cloning or updating the repository. """ - version = '1.0.0' + version = '1.0.1' CATEGORIES = [CATEGORY_COMMIT] @@ -567,7 +567,7 @@ class GitParser: (?P[^\t]+) (?:\t+(?P.+))?$""" - STATS_PATTERN = r"^(?P\d+|-)[ \t]+(?P\d+|-)[ \t]+(?P.+)$" + STATS_PATTERN = r"^(?P\d+|-)\t+(?P\d+|-)\t+(?P.+)$" EMPTY_LINE_PATTERN = r"^$" diff --git a/releases/unreleased/git-file-stats-with-whitespaces-were-not-assigned.yml b/releases/unreleased/git-file-stats-with-whitespaces-were-not-assigned.yml new file mode 100644 index 000000000..b0ef2ee39 --- /dev/null +++ b/releases/unreleased/git-file-stats-with-whitespaces-were-not-assigned.yml @@ -0,0 +1,11 @@ +--- +title: Git stats not assigned with their actions +category: fixed +author: Santiago DueƱas +issue: null +notes: > + Git stats were not assigned to their actions in + a commit for filenames that contain whitespaces. + Instead, an empty stat was created like in a + merge commit, where actions normally don't take + place. diff --git a/tests/data/git/git_log_merge.txt b/tests/data/git/git_log_merge.txt index 308414885..4419c5944 100644 --- a/tests/data/git/git_log_merge.txt +++ b/tests/data/git/git_log_merge.txt @@ -7,9 +7,9 @@ CommitDate: Tue Aug 2 19:47:06 2016 -0400 Merge tag 'for-linus-v4.8' of git://github.com/martinbrandenburg/linux -46 4 Documentation/filesystems/orangefs.txt -4 0 fs/orangefs/dcache.c -3 3 fs/orangefs/inode.c +46 4 Documentation/filesystems/orangefs.txt +4 0 fs/orangefs/dcache.c +3 3 fs/orangefs/inode.c commit 456a68ee1407a77f3e804a30dff245bb6c6b872f ce8e0b86a1e9877f42fe9453ede418519115f367 51a3b654f252210572297f47597b31527c475fb8 (HEAD -> refs/heads/master) Merge: ce8e0b8 51a3b65 diff --git a/tests/test_git.py b/tests/test_git.py index 83c5d94d3..1f2324661 100644 --- a/tests/test_git.py +++ b/tests/test_git.py @@ -1395,6 +1395,19 @@ def test_stats_pattern(self): self.assertEqual(m.group('removed'), "0") self.assertEqual(m.group('file'), "bbb/{something => something.renamed}") + # Test with files that have whitespaces + s = "5\t0\t afile.txt" + m = pattern.match(s) + self.assertEqual(m.group('added'), "5") + self.assertEqual(m.group('removed'), "0") + self.assertEqual(m.group('file'), " afile.txt") + + s = "5\t0\ta fi le.txt" + m = pattern.match(s) + self.assertEqual(m.group('added'), "5") + self.assertEqual(m.group('removed'), "0") + self.assertEqual(m.group('file'), "a fi le.txt") + def test_empty_line(self): """Test empty line pattern"""