mirror of https://github.com/sobolevn/git-secret
commit
d3cf16ea23
@ -0,0 +1,31 @@
|
|||||||
|
.\" generated with Ronn/v0.7.3
|
||||||
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||||
|
.
|
||||||
|
.TH "GIT\-SECRET\-CHANGES" "1" "May 2016" "" ""
|
||||||
|
.
|
||||||
|
.SH "NAME"
|
||||||
|
\fBgit\-secret\-changes\fR \- view diff of the hidden files\.
|
||||||
|
.
|
||||||
|
.SH "SYNOPSIS"
|
||||||
|
.
|
||||||
|
.nf
|
||||||
|
|
||||||
|
git secret changes [\-h] [\-d dir] [\-p password] <pathspec>\.\.\.
|
||||||
|
.
|
||||||
|
.fi
|
||||||
|
.
|
||||||
|
.SH "DESCRIPTION"
|
||||||
|
\fBgit\-secret\-changes\fR \- shows changes between the current version of hidden files and the ones already commited\.
|
||||||
|
.
|
||||||
|
.SH "OPTIONS"
|
||||||
|
.
|
||||||
|
.nf
|
||||||
|
|
||||||
|
\-d \- specifies `\-\-homedir` option for the `gpg`, basically use this option if your store your keys in a custom location\.
|
||||||
|
\-p \- specifies password for noinput mode, adds `\-\-passphrase` option for `gpg`\.
|
||||||
|
\-h \- shows help\.
|
||||||
|
.
|
||||||
|
.fi
|
||||||
|
.
|
||||||
|
.SH "SEE ALSO"
|
||||||
|
git\-secret\-add(1), git\-secret\-tell(1), git\-secret\-hide(1), git\-secret\-reveal(1)
|
@ -0,0 +1,22 @@
|
|||||||
|
git-secret-changes - view diff of the hidden files.
|
||||||
|
===================================================
|
||||||
|
|
||||||
|
## SYNOPSIS
|
||||||
|
|
||||||
|
git secret changes [-h] [-d dir] [-p password] <pathspec>...
|
||||||
|
|
||||||
|
|
||||||
|
## DESCRIPTION
|
||||||
|
`git-secret-changes` - shows changes between the current version of hidden files and the ones already commited.
|
||||||
|
|
||||||
|
|
||||||
|
## OPTIONS
|
||||||
|
|
||||||
|
-d - specifies `--homedir` option for the `gpg`, basically use this option if your store your keys in a custom location.
|
||||||
|
-p - specifies password for noinput mode, adds `--passphrase` option for `gpg`.
|
||||||
|
-h - shows help.
|
||||||
|
|
||||||
|
|
||||||
|
## SEE ALSO
|
||||||
|
|
||||||
|
git-secret-add(1), git-secret-tell(1), git-secret-hide(1), git-secret-reveal(1)
|
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function changes {
|
||||||
|
OPTIND=1
|
||||||
|
|
||||||
|
while getopts "hd:p:" opt; do
|
||||||
|
case "$opt" in
|
||||||
|
h) _show_manual_for "changes";;
|
||||||
|
|
||||||
|
p) passphrase=$OPTARG;;
|
||||||
|
|
||||||
|
d) homedir=$OPTARG;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
[ "$1" = "--" ] && shift
|
||||||
|
|
||||||
|
local filenames="$1"
|
||||||
|
if [[ -z "$filenames" ]]; then
|
||||||
|
# Checking if no filenames are passed, show diff for all files.
|
||||||
|
filenames=$(git secret list)
|
||||||
|
fi
|
||||||
|
|
||||||
|
local previous_commit=$(git rev-parse HEAD)
|
||||||
|
|
||||||
|
for filename in "$filenames"; do
|
||||||
|
# Meta information:
|
||||||
|
local encrypted_filename=$(_get_encrypted_filename "$filename")
|
||||||
|
local last_encrypted=$(git show "${previous_commit}:${encrypted_filename}")
|
||||||
|
|
||||||
|
# Now we have all the data required:
|
||||||
|
local decrypted=$(_decrypt "$filename" "0" "0" "$homedir" "$passphrase")
|
||||||
|
local content=$(cat "$filename")
|
||||||
|
|
||||||
|
local diff_result=$(diff <(echo "$decrypted") <(echo "$content"))
|
||||||
|
echo "changes in ${filename}: ${diff_result}"
|
||||||
|
done
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
#!/usr/bin/env bats
|
||||||
|
|
||||||
|
load _test_base
|
||||||
|
|
||||||
|
FILE_TO_HIDE="file_to_hide"
|
||||||
|
FILE_CONTENTS="hidden content юникод"
|
||||||
|
|
||||||
|
FINGERPRINT=""
|
||||||
|
|
||||||
|
|
||||||
|
function setup {
|
||||||
|
FINGERPRINT=$(install_fixture_full_key "$TEST_DEFAULT_USER")
|
||||||
|
|
||||||
|
set_state_git
|
||||||
|
set_state_secret_init
|
||||||
|
set_state_secret_tell "$TEST_DEFAULT_USER"
|
||||||
|
set_state_secret_add "$FILE_TO_HIDE" "$FILE_CONTENTS"
|
||||||
|
set_state_secret_hide
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function teardown {
|
||||||
|
uninstall_fixture_full_key "$TEST_DEFAULT_USER" "$FINGERPRINT"
|
||||||
|
unset_current_state
|
||||||
|
rm -f "$FILE_TO_HIDE"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "run 'changes' without previous commit" {
|
||||||
|
local password=$(test_user_password "$TEST_DEFAULT_USER")
|
||||||
|
local new_content="new content"
|
||||||
|
echo "$new_content" >> "$FILE_TO_HIDE"
|
||||||
|
|
||||||
|
run git secret changes -d "$TEST_GPG_HOMEDIR" -p "$password"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
|
||||||
|
# Testing that output has both filename and changes:
|
||||||
|
[[ "$output" == *"$FILE_TO_HIDE"* ]]
|
||||||
|
[[ "$output" == *"$new_content"* ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "run 'changes' without changes" {
|
||||||
|
local password=$(test_user_password "$TEST_DEFAULT_USER")
|
||||||
|
run git secret changes -d "$TEST_GPG_HOMEDIR" -p "$password"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@test "run 'changes' with commit" {
|
||||||
|
git_commit "$(test_user_email $TEST_DEFAULT_USER)" 'initial'
|
||||||
|
local password=$(test_user_password "$TEST_DEFAULT_USER")
|
||||||
|
|
||||||
|
echo "new content" >> "$FILE_TO_HIDE"
|
||||||
|
|
||||||
|
run git secret changes -d "$TEST_GPG_HOMEDIR" -p "$password"
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[[ "$output" == *"$FILE_TO_HIDE"* ]]
|
||||||
|
[[ "$output" == *"$new_content"* ]]
|
||||||
|
}
|
Loading…
Reference in New Issue