Skip to content

Commit 4290e04

Browse files
authored
Merge pull request #10 from tommarshall/v0.4.0-wip
v0.4.0
2 parents 87e8fb2 + 40a9549 commit 4290e04

File tree

7 files changed

+24
-60
lines changed

7 files changed

+24
-60
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ uninstall:
1111
setup:
1212
@rm -rf vendor
1313
@mkdir -p vendor
14-
git clone --depth 1 git://github.com/sstephenson/bats.git vendor/bats
14+
git clone --depth 1 git://github.com/sstephenson/bats.git vendor/bats
15+
git clone --depth 1 git://github.com/ztombol/bats-assert.git vendor/bats-assert
16+
git clone --depth 1 git://github.com/ztombol/bats-support.git vendor/bats-support
1517

1618
test:
1719
vendor/bats/bin/bats test

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
Running `git diff` on files encrypted with ansible vault results in some pretty unhelpful output.
66

7-
`git-diff-ansible-vault` is custom git command that detects files encrypted with ansible vault within the diff, and safely decrypts them to reveal the true changes.
7+
`git-diff-ansible-vault` is custom git utility that detects files encrypted with ansible vault within the diff, and safely decrypts them to reveal the true changes.
88

9-
![git-diff-ansible-vault animated demo](https://github.com/tommarshall/git-diff-ansible-vault/blob/master/img/demo.gif)
9+
![git-diff-ansible-vault animated demo](https://github.com/tommarshall/git-diff-ansible-vault/blob/master/demo.gif)
1010

1111
## Installation
1212

bin/git-diff-ansible-vault

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# https://github.com/tommarshall/git-diff-ansible-vault
88
#
99

10-
VERSION=0.3.0
10+
VERSION=0.4.0
1111
REVISION=
1212
PATH_SCOPE=
1313
GIT_DIFF_ARGS=
@@ -250,7 +250,7 @@ colordiff_wrap() {
250250

251251
set_default_color() {
252252
if [ -z $COLOR ]; then
253-
COLOR=$(git config --get color.ui || echo 'auto')
253+
COLOR=$(git config --get color.diff || git config --get color.ui || echo 'auto')
254254
if is_color && ! has_colordiff; then
255255
warn "Default --color '$COLOR' requires colordiff"
256256
COLOR='never'

demo.gif

300 KB
Loading

img/demo.gif

-167 KB
Binary file not shown.

test/git-diff-ansible-vault.bats

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
#!/usr/bin/env bats
22

3+
load ../vendor/bats-support/load
4+
load ../vendor/bats-assert/load
35
load test_helper
46

5-
# cd to fixture and move the git dir out of the shadows
6-
setup() {
7-
cd "$BATS_TEST_DIRNAME/fixture/repo.git"
8-
mv "git" ".git"
9-
}
10-
11-
# hide the git dir in the fixture, so we don't have to use submodules
12-
teardown() {
13-
cd "$BATS_TEST_DIRNAME/fixture/repo.git"
14-
mv ".git" "git"
15-
}
16-
177
@test "without --revision or --path shows all work-in-progress changes" {
188
run git diff-ansible-vault
199
assert_success

test/test_helper.bash

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,25 @@
33
PATH="${BATS_TEST_DIRNAME}/../bin:$PATH"
44
export PATH
55

6-
flunk() {
7-
echo "$@"
8-
return 1
9-
}
10-
11-
assert_success() {
12-
if [ "$status" -ne 0 ]; then
13-
flunk "command failed with exit status $status"
14-
elif [ "$#" -gt 0 ]; then
15-
assert_output "$1"
16-
fi
17-
}
6+
# Remember where the hook is
7+
BASE_DIR=$(dirname $BATS_TEST_DIRNAME)
8+
# Set up a directory for our git repo
9+
TMP_DIRECTORY=$(mktemp -d)
1810

19-
assert_failure() {
20-
if [ "$status" -eq 0 ]; then
21-
flunk "expected failed exit status"
22-
elif [ "$#" -gt 0 ]; then
23-
assert_output "$1"
24-
fi
11+
setup() {
12+
# copy the test fixture and move the git dir out of the shadows
13+
cp -r "$BATS_TEST_DIRNAME/fixture/repo.git" "$TMP_DIRECTORY"
14+
mv "$TMP_DIRECTORY/repo.git/git" "$TMP_DIRECTORY/repo.git/.git"
15+
cd "$TMP_DIRECTORY/repo.git"
2516
}
2617

27-
assert_equal() {
28-
if [ "$1" != "$2" ]; then
29-
{ echo "expected: $1"
30-
echo "actual: $2"
31-
} | flunk
32-
fi
33-
}
34-
35-
assert_output() {
36-
local expected
37-
if [ $# -eq 0 ]; then
38-
expected="$(cat -)"
18+
teardown() {
19+
if [ $BATS_TEST_COMPLETED ]; then
20+
echo "Deleting $TMP_DIRECTORY"
21+
rm -rf $TMP_DIRECTORY
3922
else
40-
expected="$1"
23+
echo "** Did not delete $TMP_DIRECTORY, as test failed **"
4124
fi
42-
assert_equal "$expected" "$output"
43-
}
4425

45-
assert_line() {
46-
if [ "$1" -ge 0 ] 2>/dev/null; then
47-
assert_equal "$2" "${lines[$1]}"
48-
else
49-
local line
50-
for line in "${lines[@]}"; do
51-
if [ "$line" = "$1" ]; then return 0; fi
52-
done
53-
flunk "expected line \`$1'"
54-
fi
26+
cd $BATS_TEST_DIRNAME
5527
}

0 commit comments

Comments
 (0)