Skip to content

Commit

Permalink
Add HTTP proxy support
Browse files Browse the repository at this point in the history
If git config option 'http.proxy' is set, the hook shall use it
with curl in posting a message to slack.
  • Loading branch information
oCCtet committed Feb 27, 2022
1 parent e22a0ff commit 06d872a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions git-slack-hook
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function help() {
echo " git config hooks.slack.changeset-url-pattern 'http://yourserver/%repo_path%/changeset/%rev_hash%' #optional"
echo " git config hooks.slack.compare-url-pattern 'http://yourserver/%repo_path%/changeset/%old_rev_hash%..%new_rev_hash%' #optional"
echo " git config hooks.slack.branch-regexp 'regexp' #optional"
echo " git config http.proxy 'proto://host:port' #optional"
}

function replace_variables() {
Expand Down Expand Up @@ -274,6 +275,7 @@ function notify() {
username=$(git config --get hooks.slack.username)
iconurl=$(git config --get hooks.slack.icon-url)
iconemoji=$(git config --get hooks.slack.icon-emoji)
http_proxy=$(git config --get http.proxy)

if [ -z "$webhook_url" ]; then
echo "ERROR: config settings not found"
Expand Down Expand Up @@ -306,6 +308,7 @@ function notify() {
fi

curl -s \
${http_proxy:+-x $http_proxy} \
-d "payload=$payload" \
"$webhook_url" \
>/dev/null
Expand Down

0 comments on commit 06d872a

Please sign in to comment.