-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtravis.sh
More file actions
executable file
·39 lines (37 loc) · 2.27 KB
/
travis.sh
File metadata and controls
executable file
·39 lines (37 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
export DOMAIN=$(echo $TRAVIS_BRANCH | cut -d '=' -f 1)
export ISSUE=$(echo $TRAVIS_BRANCH | cut -d '=' -f 2)
export GITHUB_NAME=$(echo $TRAVIS_REPO_SLUG | cut -d '/' -f 1)
export PATH=~/bin:$PATH
USER=$(curl $(curl https://api.github.com/repos/$TRAVIS_REPO_SLUG/issues/$ISSUE | jq -r '.user.url'))
git config --global user.email $(echo $USER | jq -e '.email' > /dev/null && echo $USER | jq -r '.email' || echo $(echo $USER | jq -r '.login')@users.noreply.github.com)
git config --global user.name "$(echo $USER | jq -e '.name' > /dev/null && echo $USER | jq -r '.name' || echo $USER | jq -r '.login')"
echo -e "machine github.com\nlogin $GITHUB_NAME\npassword $GITHUB_TOKEN" >> ~/.netrc
mkdir ~/.config || true
echo -e "---\ngithub.com:\n- oauth_token: $GITHUB_TOKEN\n user: $GITHUB_NAME" >> ~/.config/hub
wget https://github.com/galeksandrp/https-everywhere/archive/check-sublist3r.tar.gz -O - | tar xz
mv https-everywhere-check-sublist3r ~/workspace
wget https://github.com/aboul3la/Sublist3r/archive/master.tar.gz -O - | tar xz
mv Sublist3r-master ~/workspace/Sublist3r
git remote add upstream https://github.com/EFForg/https-everywhere.git
git remote add fork https://github.com/$GITHUB_NAME/https-everywhere.git
checkoutBranch(){
git show fork/$DOMAIN:test/fetch.sh > /dev/null || (git fetch --unshallow fork $DOMAIN && git fetch upstream master)
git checkout -b $DOMAIN fork/$DOMAIN
git show fork/$DOMAIN:test/fetch.sh > /dev/null || git rebase upstream/master
}
git fetch --depth=50 fork $DOMAIN && checkoutBranch || (git fetch --depth=50 upstream master && git checkout -b $DOMAIN upstream/master)
wget https://github.com/github/hub/releases/download/v2.2.8/hub-linux-amd64-2.2.8.tgz -O - | tar xz --strip=1 -C ~ hub-linux-amd64-2.2.8
chmod +x ~/workspace/Sublist3r/sublist3r.py ~/workspace/*.sh
cd src/chrome/content/rules
FILE=$(grep "<target host=\"$DOMAIN\"" -l *.xml) || FILE=$DOMAIN.xml
~/workspace/generate.sh $DOMAIN "$FILE" || exit 1
if [ $(xmllint --xpath 'count(//target)' "$FILE") -eq 0 ]; then
exit 1
fi
git add "$FILE"
git commit -m "$DOMAIN fix $TRAVIS_REPO_SLUG#$ISSUE"
git push -f -u fork $DOMAIN
echo $DOMAIN > ~/pr.txt
echo '' >> ~/pr.txt
echo Issue author: @$(echo $USER | jq -r '.login') >> ~/pr.txt
if [ $ISSUE -ne 2 ]; then hub pull-request -h $GITHUB_NAME:$DOMAIN -F ~/pr.txt; fi