Skip to content

Commit

Permalink
Merge pull request #1 from mvidner/master
Browse files Browse the repository at this point in the history
Added a new script; replaced github-secrets by ~/.netrc
  • Loading branch information
jreidinger committed Jun 19, 2012
2 parents 1af0d6c + 6138070 commit c5a30b9
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 4 deletions.
1 change: 1 addition & 0 deletions github-scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json-*
2 changes: 1 addition & 1 deletion github-scripts/github-create-email-hook
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ do
}
EOJSON

curl -s -u ${username}:${password} -X POST -d @${json} https://api.github.com/repos/${organization}/${repo}/hooks -o ${json}.result
curl -s -n -X POST -d @${json} https://api.github.com/repos/${organization}/${repo}/hooks -o ${json}.result
done


37 changes: 37 additions & 0 deletions github-scripts/github-disable-email-hook
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash
# When recovering the broken svn-git migration,
# we needed to temporarily disable the commit email notifications.

# Stop on errors.
set -e

# Check that ~/.netrc knows github
. github-secrets

organization="yast"
# Get the list from http://zq1.de/bernhard/yast-broken-list.txt
repolist=`sed 's/^/yast-/' yast-broken-list.txt`

for repo in $repolist
do
echo -n $repo...
curl -f -s -n https://api.github.com/repos/${organization}/${repo}/hooks -o ${json}.list
if [ $(grep '"id"' ${json}.list | wc -l) != 1 ]; then
echo "$repo has more than one hook. fix manually"
touch ${repo}.error
continue
fi
ID=$(sed -n 's/.*"id": \([0-9]*\).*/\1/;T;p;q' ${json}.list)
json=json-${repo}
cat > ${json} << EOJSON
{
"name": "email",
"active": false,
"config": {
"address": "yast-commit@opensuse.org"
}
}
EOJSON
curl -f -s -n -X PATCH -d @${json} https://api.github.com/repos/${organization}/${repo}/hooks/$ID -o ${json}.result
echo " OK"
done
13 changes: 10 additions & 3 deletions github-scripts/github-secrets
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
username="johndoe"
password="yourpassword"

# This file used to define the shell variables `username` and `password`
# but then they would show up in output of `ps`, `bash -x`...
# It is better to use `~/.netrc` which `curl -n` will use.
if ! grep -qs api.github.com ~/.netrc; then
echo "Set up your Github credentials first:"
echo " : >> ~/.netrc"
echo " chmod 600 ~/.netrc"
echo " echo 'machine api.github.com login USER password PASSWORD' >> ~/.netrc"
exit 1
fi

0 comments on commit c5a30b9

Please sign in to comment.