Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commitc9b44d2
committed
fix files list on file rename
GitPython parses the output of `git diff --numstat` to get thefiles changed in a commit.This breaks when a commit contains a file rename, because the outputof `git diff` is different than expected.This is the output of a normal commit: $ git diff --numstat8f41a39^8f41a39 30 5 test/test_repo.pyAnd this a commit containing a rename: $ git diff --numstat185d847^185d847 3 1 .github/workflows/{test_pytest.yml => Future.yml}This can be triggered by this code: for commit in repo.iter_commits(): print(commit.hexsha) for file in commit.stats.files: print(file)Which will print for the normal commit:8f41a39 'test/test_repo.py'And when there is a rename:185d847 '.github/workflows/{test_pytest.yml => Future.yml}'Additionally, when a path member is removed, the file list becomea list of strings, breaking even more the caller. This is in theLinux kernel tree: $ git diff --numstat db401875f438^ db401875f438 1 1 tools/testing/selftests/drivers/net/mlxsw/{spectrum-2 => }/devlink_trap_tunnel_ipip6.shand GitPython parses it as: db401875f438168c5804b295b93a28c7730bb57a ('tools/testing/selftests/drivers/net/mlxsw/{spectrum-2 => ' '}/devlink_trap_tunnel_ipip6.sh')Fix this by pasing the --no-renames option to `git diff` which ignoresrenames and print the same output as if the file was deleted from theold path and created in the new one: $ git diff --numstat --no-renames185d847^185d847 57 0 .github/workflows/Future.yml 0 55 .github/workflows/test_pytest.yml1 parent90c81a5 commitc9b44d2
2 files changed
+33
-2
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
324 | 324 |
| |
325 | 325 |
| |
326 | 326 |
| |
327 |
| - | |
| 327 | + | |
328 | 328 |
| |
329 | 329 |
| |
330 | 330 |
| |
331 | 331 |
| |
332 | 332 |
| |
333 | 333 |
| |
334 |
| - | |
| 334 | + | |
335 | 335 |
| |
336 | 336 |
| |
337 | 337 |
| |
|
Lines changed: 31 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
159 | 159 |
| |
160 | 160 |
| |
161 | 161 |
| |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
162 | 193 |
| |
163 | 194 |
| |
164 | 195 |
| |
|
0 commit comments
Comments
(0)