Commit 0cbfd249 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Added a new command 'installed'

New command 'installed' lists the scripts installed in a hook directory.
Among other uses it will be useful for bash_completion implementations.
parent 54da04a9
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -80,12 +80,17 @@ cmd_init ()
	done
}

_add_remove_check ()
_basic_check ()
{
	contains "$HOOKS" "$hook" || die "unknown hook '$hook'"
	[ -d "$GIT_DIR"/hooks/$hook.d ] || \
		die "the '$hook' hook directory does not appear to exist, you should \
		     run 'git-hooks init'"
}

_add_remove_check ()
{
	_basic_check
	[ -w "$GIT_DIR"/hooks/$hook.d ] || \
		die "you do not have permissions to add the script to \
		     $GIT_DIR/hooks/$hook.d"
@@ -123,6 +128,18 @@ cmd_remove ()
	rm "$GIT_DIR"/hooks/$hook.d/"$script"
}

cmd_installed ()
{
	summary="show scripts installed under a hook"
	local hook
	add_option hook yes
	parse_args "$@" || return
	_basic_check

	cd "$GIT_DIR"/hooks/$hook.d
	find -type f -printf '%P\n'
}

cmd_help ()
{
	summary="show this help message"