| 52 | return version |
| 53 | |
| 54 | def get_blame_list(self): |
| 55 | logging.info(f"blame list for {self.path}") |
| 56 | result = subprocess.check_output( |
| 57 | ['git', 'blame', '-t', '--line-porcelain', self.path], |
| 58 | encoding='UTF-8') |
| 59 | line_iter = iter(result.splitlines()) |
| 60 | blame_list = list() |
| 61 | current_blame = None |
| 62 | while True: |
| 63 | line = next(line_iter, None) |
| 64 | if line is None: |
| 65 | break |
| 66 | if RE_GITHASH.match(line): |
| 67 | if current_blame is not None: |
| 68 | blame_list.append(current_blame) |
| 69 | hash = line.split(" ")[0] |
| 70 | current_blame = { |
| 71 | 'datetime': 0, |
| 72 | 'filename': None, |
| 73 | 'content': None, |
| 74 | 'hash': hash |
| 75 | } |
| 76 | continue |
| 77 | match = RE_AUTHOR_TIME.match(line) |
| 78 | if match: |
| 79 | current_blame['datetime'] = datetime.fromtimestamp( |
| 80 | int(match.groups()[0])) |
| 81 | continue |
| 82 | match = RE_FILENAME.match(line) |
| 83 | if match: |
| 84 | current_blame['filename'] = match.groups()[0] |
| 85 | current_blame['content'] = next(line_iter).strip() |
| 86 | continue |
| 87 | blame_list.append(current_blame) |
| 88 | return blame_list |
| 89 | |
| 90 | def filter_and_print(self, macro, options): |
| 91 | before = options.before |