| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | test_description='colored git blame' |
| 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | |
| 7 | TEST_CREATE_REPO_NO_TEMPLATE=1 |
| 8 | . ./test-lib.shscip-shell source . . `./test-lib.sh`. |
| 9 | |
| 10 | if ! test_have_prereq PERL_TEST_HELPERS |
| 11 | then |
| 12 | skip_all='skipping blame colors tests; Perl not available' |
| 13 | test_done |
| 14 | fi |
| 15 | |
| 16 | PROG='git blame -c' |
| 17 | . "$TEST_DIRECTORY"/annotate-tests.sh |
| 18 | |
| 19 | test_expect_success 'colored blame colors contiguous lines' ' |
| 20 | git -c color.blame.repeatedLines=yellow blame --color-lines --abbrev=12 hello.c >actual.raw && |
| 21 | git -c color.blame.repeatedLines=yellow -c blame.coloring=repeatedLines blame --abbrev=12 hello.c >actual.raw.2 && |
| 22 | test_cmp actual.raw actual.raw.2 && |
| 23 | test_decode_color <actual.raw >actual && |
| 24 | grep "<YELLOW>" <actual >darkened && |
| 25 | grep "(F" darkened > F.expect && |
| 26 | grep "(H" darkened > H.expect && |
| 27 | test_line_count = 2 F.expect && |
| 28 | test_line_count = 3 H.expect |
| 29 | ' |
| 30 | |
| 31 | test_expect_success 'color by age consistently colors old code' ' |
| 32 | git blame --color-by-age hello.c >actual.raw && |
| 33 | git -c blame.coloring=highlightRecent blame hello.c >actual.raw.2 && |
| 34 | test_cmp actual.raw actual.raw.2 && |
| 35 | test_decode_color <actual.raw >actual && |
| 36 | grep "<BLUE>" <actual >colored && |
| 37 | test_line_count = 10 colored |
| 38 | ' |
| 39 | |
| 40 | test_expect_success 'blame color by age: new code is different' ' |
| 41 | cat >>hello.c <<-EOF && |
| 42 | void qfunc(); |
| 43 | EOF |
| 44 | git add hello.c && |
| 45 | GIT_AUTHOR_DATE="" git commit -m "new commit" && |
| 46 | |
| 47 | git -c color.blame.highlightRecent="yellow,1 month ago, cyan" blame --color-by-age hello.c >actual.raw && |
| 48 | test_decode_color <actual.raw >actual && |
| 49 | |
| 50 | grep "<YELLOW>" <actual >colored && |
| 51 | test_line_count = 10 colored && |
| 52 | |
| 53 | grep "<CYAN>" <actual >colored && |
| 54 | test_line_count = 1 colored && |
| 55 | grep qfunc colored |
| 56 | ' |
| 57 | |
| 58 | test_done |