Skip to content

Commit db3942b

Browse files
committed
Refactor the call to curl in add-default-github-hooks
... in preparation for two-factor authentication... Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 17523cc commit db3942b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

add-default-github-hooks.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@ die "Usage: $0 <org>/<repository>"
1313

1414
repository="$1"
1515

16+
mycurl () {
17+
curl --netrc "$@" "$url"
18+
}
19+
1620
url="https://api.github.com/repos/$repository/hooks"
17-
hooks="$(curl --netrc "$url")"
21+
hooks="$(mycurl)"
1822

1923
# IRC
2024
if ! echo "$hooks" | grep '^ "name": "irc",$'
2125
then
2226
echo "Adding IRC hook"
23-
curl --netrc -XPOST -d '{"name":"irc","active":true,"events":["push","pull_request"],"config":{"server":"irc.freenode.net","port":"6667","room":"#imagejdev","message_without_join":"1","notice":"1"}}' "$url"
27+
mycurl -XPOST -d '{"name":"irc","active":true,"events":["push","pull_request"],"config":{"server":"irc.freenode.net","port":"6667","room":"#imagejdev","message_without_join":"1","notice":"1"}}'
2428
fi
2529

2630
# Jenkins
2731
if ! echo "$hooks" | grep '^ "name": "jenkinsgit",$'
2832
then
2933
echo "Adding Jenkins hook"
30-
curl --netrc -XPOST -d '{"name":"jenkinsgit","active":true,"events":["push"],"config":{"jenkins_url":"http://jenkins.imagej.net/"}}' "$url"
34+
mycurl -XPOST -d '{"name":"jenkinsgit","active":true,"events":["push"],"config":{"jenkins_url":"http://jenkins.imagej.net/"}}'
3135
fi

0 commit comments

Comments
 (0)