| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 90c81a5 commit c9b44d2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -324,14 +324,14 @@ def stats(self) -> Stats: | |||
| 324 | 324 | ||
| 325 | 325 | :return: git.Stats""" | |
| 326 | 326 | if not self.parents: | |
| 327 | - text = self.repo.git.diff_tree(self.hexsha, "--", numstat=True, root=True) | ||
| 327 | + text = self.repo.git.diff_tree(self.hexsha, "--", numstat=True, no_renames=True, root=True) | ||
| 328 | 328 | text2 = "" | |
| 329 | 329 | for line in text.splitlines()[1:]: | |
| 330 | 330 | (insertions, deletions, filename) = line.split("\t") | |
| 331 | 331 | text2 += "%s\t%s\t%s\n" % (insertions, deletions, filename) | |
| 332 | 332 | text = text2 | |
| 333 | 333 | else: | |
| 334 | - text = self.repo.git.diff(self.parents[0].hexsha, self.hexsha, "--", numstat=True) | ||
| 334 | + text = self.repo.git.diff(self.parents[0].hexsha, self.hexsha, "--", numstat=True, no_renames=True) | ||
| 335 | 335 | return Stats._list_from_string(self.repo, text) | |
| 336 | 336 | ||
| 337 | 337 | @property | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,6 +159,37 @@ def check_entries(d): | |||
| 159 | 159 | self.assertEqual(commit.committer_tz_offset, 14400, commit.committer_tz_offset) | |
| 160 | 160 | self.assertEqual(commit.message, "initial project\n") | |
| 161 | 161 | ||
| 162 | + def test_renames(self): | ||
| 163 | + commit = self.rorepo.commit("185d847ec7647fd2642a82d9205fb3d07ea71715") | ||
| 164 | + files = commit.stats.files | ||
| 165 | + | ||
| 166 | + # when a file is renamed, the output of git diff is like "dir/{old => new}" | ||
| 167 | + # unless we disable rename with --no-renames, which produces two lines | ||
| 168 | + # one with the old path deletes and another with the new added | ||
| 169 | + self.assertEqual(len(files), 2) | ||
| 170 | + | ||
| 171 | + def check_entries(path, changes): | ||
| 172 | + expected = { | ||
| 173 | + ".github/workflows/Future.yml" : { | ||
| 174 | + 'insertions': 57, | ||
| 175 | + 'deletions': 0, | ||
| 176 | + 'lines': 57 | ||
| 177 | + }, | ||
| 178 | + ".github/workflows/test_pytest.yml" : { | ||
| 179 | + 'insertions': 0, | ||
| 180 | + 'deletions': 55, | ||
| 181 | + 'lines': 55 | ||
| 182 | + }, | ||
| 183 | + } | ||
| 184 | + assert path in expected | ||
| 185 | + assert isinstance(changes, dict) | ||
| 186 | + for key in ("insertions", "deletions", "lines"): | ||
| 187 | + assert changes[key] == expected[path][key] | ||
| 188 | + | ||
| 189 | + for path, changes in files.items(): | ||
| 190 | + check_entries(path, changes) | ||
| 191 | + # END for each stated file | ||
| 192 | + | ||
| 162 | 193 | def test_unicode_actor(self): | |
| 163 | 194 | # assure we can parse unicode actors correctly | |
| 164 | 195 | name = "Üäöß ÄußÉ" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments