-
Notifications
You must be signed in to change notification settings - Fork 4
/
create_pull_request_for_precompiled_code.sh
executable file
·72 lines (58 loc) · 1.82 KB
/
create_pull_request_for_precompiled_code.sh
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -e
set -u
SCRIPT=$(realpath $0)
SCRIPTPATH=$(dirname $SCRIPT)
PACKAGE="$1"
TOKEN=$(git config --get github.token || echo)
if [ "x$TOKEN" = x ] && [ -r ~/.github_shell_token ] ; then
TOKEN=$(cat ~/.github_shell_token)
fi
if [ "x$TOKEN" = x ] ; then
error "could not determine GitHub access token"
fi
API_URL=https://api.github.com/repos/homalg-project/$PACKAGE/pulls
DATE=$(date +%s)
VERSION=`gap --banner --quiet -A <( echo 'LoadPackage( "CompilerForCAP" ); Print( Last( GAPInfo.PackagesInfo.compilerforcap ).Version, "\n" ); QUIT_GAP();') | tr -d '\r'`
mkdir -p "/tmp/$DATE/pkg"
echo '(function()
local name, package_info, pos;
for name in RecNames( GAPInfo.PackagesInfo ) do
if name = "io" then
continue;
fi;
package_info := GAPInfo.PackagesInfo.(name);
pos := PositionProperty( package_info, info -> StartsWith( info.InstallationPath, "../../" ) );
if pos <> fail then
SetPackagePath( name, package_info[pos].InstallationPath );
fi;
od;
end)();' > "/tmp/$DATE/gaprc"
cd "/tmp/$DATE/pkg"
git clone [email protected]:homalg-project/$PACKAGE.git
cd $PACKAGE
make doc
/usr/bin/gap -l "../../;~/.gap/;" -r tst/testall.g || echo "Changes found"
read -p "Please review all changes in \"file:///tmp/$DATE/pkg/$PACKAGE/\" and enter y to proceed. " -n 1
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
if [ -n "$(git status --porcelain)" ]; then
echo "Create PR"
git add -A
git commit -m "Adjust to CompilerForCAP $VERSION"
git push origin master:"CompilerForCAP-$VERSION"
DATA=$(cat <<EOF
{
"title": "Adjust to CompilerForCAP $VERSION",
"head": "CompilerForCAP-$VERSION",
"base": "master",
"body": ""
}
EOF
)
response=$(curl -s -S -H "Content-Type: application/json" -X POST --data "$DATA" "$API_URL" -H "Authorization: token $TOKEN")
else
echo "No changes"
fi