Determine the first common ancestor commit. Find diff between branch and FCA commit. Note: if `uncommitted` is set, check only uncommitted changes
(self, uncommitted = False)
| 27 | self.head = self.repo.head.commit |
| 28 | |
| 29 | def get_branch_diff(self, uncommitted = False): |
| 30 | """ |
| 31 | Determine the first common ancestor commit. |
| 32 | Find diff between branch and FCA commit. |
| 33 | Note: if `uncommitted` is set, check only |
| 34 | uncommitted changes |
| 35 | """ |
| 36 | try: |
| 37 | commit = self.repo.merge_base(self.branch, self.head)[0] |
| 38 | except exc.GitCommandError: |
| 39 | print(f"Branch with name `{self.branch}` does not exist") |
| 40 | sys.exit(1) |
| 41 | |
| 42 | exclude = [f':(exclude){i}' for i in EXCLUDE] |
| 43 | if uncommitted: |
| 44 | diff = self.repo.git.diff( |
| 45 | self.head, '--unified=0', '***.py', *exclude |
| 46 | ) |
| 47 | else: |
| 48 | diff = self.repo.git.diff( |
| 49 | commit, self.head, '--unified=0', '***.py', *exclude |
| 50 | ) |
| 51 | return diff |
| 52 | |
| 53 | def run_pycodestyle(self, diff): |
| 54 | """ |