Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ uninstall:
setup:
@rm -rf vendor
@mkdir -p vendor
git clone --depth 1 git://github.com/sstephenson/bats.git vendor/bats
git clone --depth 1 git://github.com/sstephenson/bats.git vendor/bats
git clone --depth 1 git://github.com/ztombol/bats-assert.git vendor/bats-assert
git clone --depth 1 git://github.com/ztombol/bats-support.git vendor/bats-support

test:
vendor/bats/bin/bats test
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

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

`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.
`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.

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

## Installation

Expand Down
4 changes: 2 additions & 2 deletions bin/git-diff-ansible-vault
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# https://github.com/tommarshall/git-diff-ansible-vault
#

VERSION=0.3.0
VERSION=0.4.0
REVISION=
PATH_SCOPE=
GIT_DIFF_ARGS=
Expand Down Expand Up @@ -250,7 +250,7 @@ colordiff_wrap() {

set_default_color() {
if [ -z $COLOR ]; then
COLOR=$(git config --get color.ui || echo 'auto')
COLOR=$(git config --get color.diff || git config --get color.ui || echo 'auto')
if is_color && ! has_colordiff; then
warn "Default --color '$COLOR' requires colordiff"
COLOR='never'
Expand Down
Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/demo.gif
Binary file not shown.
14 changes: 2 additions & 12 deletions test/git-diff-ansible-vault.bats
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
#!/usr/bin/env bats

load ../vendor/bats-support/load
load ../vendor/bats-assert/load
load test_helper

# cd to fixture and move the git dir out of the shadows
setup() {
cd "$BATS_TEST_DIRNAME/fixture/repo.git"
mv "git" ".git"
}

# hide the git dir in the fixture, so we don't have to use submodules
teardown() {
cd "$BATS_TEST_DIRNAME/fixture/repo.git"
mv ".git" "git"
}

@test "without --revision or --path shows all work-in-progress changes" {
run git diff-ansible-vault
assert_success
Expand Down
58 changes: 15 additions & 43 deletions test/test_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,25 @@
PATH="${BATS_TEST_DIRNAME}/../bin:$PATH"
export PATH

flunk() {
echo "$@"
return 1
}

assert_success() {
if [ "$status" -ne 0 ]; then
flunk "command failed with exit status $status"
elif [ "$#" -gt 0 ]; then
assert_output "$1"
fi
}
# Remember where the hook is
BASE_DIR=$(dirname $BATS_TEST_DIRNAME)
# Set up a directory for our git repo
TMP_DIRECTORY=$(mktemp -d)

assert_failure() {
if [ "$status" -eq 0 ]; then
flunk "expected failed exit status"
elif [ "$#" -gt 0 ]; then
assert_output "$1"
fi
setup() {
# copy the test fixture and move the git dir out of the shadows
cp -r "$BATS_TEST_DIRNAME/fixture/repo.git" "$TMP_DIRECTORY"
mv "$TMP_DIRECTORY/repo.git/git" "$TMP_DIRECTORY/repo.git/.git"
cd "$TMP_DIRECTORY/repo.git"
}

assert_equal() {
if [ "$1" != "$2" ]; then
{ echo "expected: $1"
echo "actual: $2"
} | flunk
fi
}

assert_output() {
local expected
if [ $# -eq 0 ]; then
expected="$(cat -)"
teardown() {
if [ $BATS_TEST_COMPLETED ]; then
echo "Deleting $TMP_DIRECTORY"
rm -rf $TMP_DIRECTORY
else
expected="$1"
echo "** Did not delete $TMP_DIRECTORY, as test failed **"
fi
assert_equal "$expected" "$output"
}

assert_line() {
if [ "$1" -ge 0 ] 2>/dev/null; then
assert_equal "$2" "${lines[$1]}"
else
local line
for line in "${lines[@]}"; do
if [ "$line" = "$1" ]; then return 0; fi
done
flunk "expected line \`$1'"
fi
cd $BATS_TEST_DIRNAME
}