diff options
author | Drew DeVault <sir@cmpwn.com> | 2019-03-30 15:01:24 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-03-30 15:01:24 -0400 |
commit | 411e247a80302bac1137c81d7fa793f7ddca9a0e (patch) | |
tree | 1e802f2d98b1a582f02c69fb3f576bd654fb4adc | |
parent | fa04a1e036a418258451466d99de34a9546a9965 (diff) | |
download | aerc-411e247a80302bac1137c81d7fa793f7ddca9a0e.tar.gz |
Update hldiff.py to match git more closely
-rwxr-xr-x | contrib/hldiff.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/contrib/hldiff.py b/contrib/hldiff.py index e12f688..367dcda 100755 --- a/contrib/hldiff.py +++ b/contrib/hldiff.py @@ -5,20 +5,28 @@ import re patch = sys.stdin.read().replace("\r\n", "\n") stat_re = re.compile(r'(\+*)(\-*)') +lines_re = re.compile(r'@@ (-\d+,\d+ \+\d+,\d+) @@') hit_diff = False for line in patch.split("\n"): if line.startswith("diff "): hit_diff = True - print(line) + print(f"{Style.BRIGHT}{line}{Style.RESET_ALL}") continue if hit_diff: if line.startswith("-"): print(f"{Fore.RED}{line}{Style.RESET_ALL}") elif line.startswith("+"): print(f"{Fore.GREEN}{line}{Style.RESET_ALL}") - else: + elif line.startswith(" "): print(line) + else: + if line.startswith("@@"): + line = lines_re.sub(f"{Fore.BLUE}@@ \\1 @@{Style.RESET_ALL}", + line) + print(line) + else: + print(f"{Style.BRIGHT}{line}{Style.RESET_ALL}") else: if line.startswith(" ") and "|" in line and ("+" in line or "-" in line): line = stat_re.sub( |