简体   繁体   中英

git hook suitable for checking changes in pull code

As mentioned in the question, after or at the time of pulling modified code to my production base i want to notify others about changes are going to be done to my production base or changes took place in production base through emails.

git-hooks mentioned here doesn't match with my criteria.

Can any one suggest me a hook/script/gem that can do my job with example?

Thanks a lot in advance.

EDIT: Can any one give me a sample of post-merge hook

it is duplicate of Is there any git hook for pull?

For customising your request and refer this url https://gist.github.com/sindresorhus/7996717 , you can prepare the hook post-merge as below

#/usr/bin/env bash

# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.

changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"

check_run() {
    echo "$changed_files" | mailx -s "changes found on production server!" your.mail.box@mail.com
}

# In this example it's used to send mail if there are any files changed.
check_run 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM