Enhanced version control init

This commit is contained in:
Jon-William Lewis
2016-08-26 14:52:45 -05:00
parent a10aca70dc
commit 2641733128
4 changed files with 19 additions and 4 deletions

View File

@@ -15,6 +15,8 @@
# Brian Mattern <rephorm@rephorm.com>. All Rights Reserved.
# This file is licensed under the GPLv2+. Please see COPYING for more information.
if [ -r "$HOME"/.local/sns/sns.conf ]; then source "$HOME"/.local/sns/sns.conf; fi
_sns_complete_entries () {
prefix="${SNS_STORE_DIR:-$HOME/.local/sns/notes/}"
suffix=".note"
@@ -66,7 +68,7 @@ _sns_complete_folders () {
_sns_complete_keys () {
local IFS=$'\n'
# Extract names and email addresses from gpg --list-keys
local keys="$(gpg2 --list-secret-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')"
local keys="$(gpg2 --list-keys --with-colons | cut -d : -f 10 | sort -u | sed '/^$/d')"
COMPREPLY+=($(compgen -W "${keys}" -- ${cur}))
}
@@ -75,7 +77,7 @@ _sns()
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
local commands="--create --config --delete --edit --help --print --list --init\
-c -d -e -h -p -l -i"
-c "$VCTL" -d -e -h -p -l -i"
if [[ $COMP_CWORD -gt 1 ]]; then
local lastarg="${COMP_WORDS[$COMP_CWORD-1]}"
case "${COMP_WORDS[1]}" in

View File

@@ -117,6 +117,12 @@ if [ "$ENCRYPTION" == "TRUE" ]; then
fi
fi
# If $VCTL is defined, add the edited note to the repo.
if [ "$VCTL" ]; then
>&2 printf "%s %s %s\n" "- adding to" "$VCTL" "repo".
verctl "$VCTL" add ""$NOTES_DIR"/$NOTE"
verctl "$VCTL" commit -m "Added/Changed $NOTE" > /dev/null
fi
}
function help {
printf "\n%s" "usage: sns [-cedlp] <notebook/section/name>"

View File

@@ -54,7 +54,7 @@ else
fi
if [ "$WILL_INIT" == "TRUE" ]; then
printf "%s\n" "- Environment initialized in $ROOT_DIR"
printf "%s\n" "- Store initialized in $ROOT_DIR"
else
printf "%s\n" "- Store already initialized."
fi
@@ -70,3 +70,10 @@ function verify_store {
fi
done
}
function verctl {
"$@"
if [ $2 == "init" ]; then
"$VCTL" add .
"$VCTL" commit -m "Initial Commit"
fi
}

View File

@@ -145,7 +145,7 @@ else
;;
"$VCTL")
cd "$ROOT_DIR"
"${@:$INDEX}"
verctl "${@:$INDEX}"
exit 0
;;
*)