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
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ Security - in case of vulnerabilities.

## [Unreleased]
### Added
- Added hook `disallow-commits`
- Added hook `conventional-commit`
- Added hook `php-cs-fixer`
- Added hook `disallow-commits`.
- Added hook `conventional-commit`.
- Added hook `php-cs-fixer`.
- Added help to all hooks, available on running hook with argument `-h` or `--help`.

## Changed
- Allowed multiple commands per file patterns in the `files-watcher`.


## [1.1.0] 2019-03-01
### Added
- Added hook `motivation`
- Added hook `files-watcher`
- Added hook `motivation`.
- Added hook `files-watcher`.

## [1.0.0] 2019-03-01
Initial release.
49 changes: 30 additions & 19 deletions files-watcher/files-watcher
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ FCS='\033[0;37m' # Light gray (silver)
NC='\033[0m'

CMD="files-watcher"
VERSION="1.0.0"
VERSION="1.1.0"
HOME="https://github.com/slavcodev/git-hooks-scripts"
ABOUT="${FCG}Files watcher${NC} version ${FCY}$VERSION${NC}"
HELP="$ABOUT
Expand All @@ -50,6 +50,7 @@ ${FCS}~~~
mode = \"auto\"

[${CMD} \"composer\.(json|lock)$\"]
command = \"composer self-update\"
command = \"composer install -n\"

[${CMD} \".php$\"]
Expand Down Expand Up @@ -100,7 +101,7 @@ main() {
fi

watch_tasks_config_pattern=files-watcher\..\*\.command
watch_tasks=$(git config --name-only --get-regexp ${watch_tasks_config_pattern})
watch_tasks=$(git config --name-only --get-regexp ${watch_tasks_config_pattern} | sort -u)

if [[ -z ${watch_tasks} ]]; then
exit
Expand All @@ -122,7 +123,6 @@ main() {

changed_files=$(git diff HEAD@\{1\} --name-only --diff-filter=ACMRTUXB | grep -iE ${pattern})

command=$(git config --type path --get ${task})
mode=$(git config --default ${default_mode} --get ${task%.*}.mode)

if [[ -n ${changed_files} ]]; then
Expand All @@ -132,23 +132,34 @@ main() {
echo "- ${FCS}${file}${NC}"
done

case "${mode}" in
"auto" )
command ${command}
;;
"prompt" )
if prompt "Do you like to run '${command}'?"; then
command ${command}
fi
;;
"confirm" )
if confirm "Do you like to run '${command}'?"; then
previous_ifs=${IFS}
IFS='
'
commands="$(git config --type path --get-all ${task})"

set -f
for command in ${commands} ; do
case "${mode}" in
"auto" )
command ${command}
fi
;;
* )
echo "${FCR}Invalid mode option${NC}"
esac
;;
"prompt" )
if prompt "Do you like to run '${command}'?"; then
command ${command}
fi
;;
"confirm" )
if confirm "Do you like to run '${command}'?"; then
command ${command}
fi
;;
* )
echo "${FCR}Invalid mode option${NC}"
esac
done
set +f

IFS=${previous_ifs}
fi
done

Expand Down