aboutsummaryrefslogtreecommitdiff
path: root/lib/keyringer/functions
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-02-25 13:00:50 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-02-25 13:00:50 -0300
commita7afc30ecce868a396f5df2ca6d42059dbcdc958 (patch)
tree791780984527aaf1344ee61b1353ea7ef635efbc /lib/keyringer/functions
parent01a7518bcef3cdb1d3816ef9443373243f6510ed (diff)
downloadkeyringer-a7afc30ecce868a396f5df2ca6d42059dbcdc958.tar.gz
keyringer-a7afc30ecce868a396f5df2ca6d42059dbcdc958.tar.bz2
New function keyringer_check_repository
Diffstat (limited to 'lib/keyringer/functions')
-rwxr-xr-xlib/keyringer/functions34
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 4746859..e594fd1 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -301,6 +301,11 @@ function keyringer_set_env {
# Upgrade configuration
keyringer_upgrade
+ # Check repository integrity
+ if [ "$BASENAME" == "check" ]; then
+ keyringer_check_repository
+ fi
+
# Check recipients file
keyringer_check_recipients $SUBCOMMAND
@@ -513,6 +518,28 @@ function keyringer_usage {
fi
}
+# Check repository integrity
+function keyringer_check_repository {
+ # Check if it's a git repository
+ if [ ! -d "$BASEDIR/.git" ]; then
+ echo "Fatal: not a git repository: $BASEDIR"
+ exit 1
+ fi
+
+ # Git maintenance operations
+ echo "Running git maintenance operations..."
+ keyringer_exec git "$BASEDIR" fsck
+ keyringer_exec git "$BASEDIR" gc --prune=all
+ echo ""
+
+ # Sync the repository
+ if [ "`keyringer_exec git "$BASEDIR" remote | wc -l`" != "0" ]; then
+ echo "Syncing git repository..."
+ keyringer_exec git "$BASEDIR" pull
+ echo ""
+ fi
+}
+
# Check recipients
# TODO: break in smaller pieces
function keyringer_check_recipients {
@@ -524,13 +551,6 @@ function keyringer_check_recipients {
# Local variables
local processed=":"
- # Sync the repository
- if [ "$BASENAME" == "check" ]; then
- echo "Syncing git repository..."
- keyringer_exec git "$BASEDIR" pull
- echo ""
- fi
-
# Check if recipients file is empty.
if [ "`grep -vE "^#|^$" "$RECIPIENTS"/* | wc -l`" == 0 ] && [ "$SUBCOMMAND" != "edit" ]; then
echo "Fatal: no recipients configured for this keyring."