-
Notifications
You must be signed in to change notification settings - Fork 3
/
post-receive
executable file
·37 lines (29 loc) · 1.17 KB
/
post-receive
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
#!/usr/bin/env python3
#
# post-receive hook to start a package build
#
import os
import sys
from request_build import request_build
from utils import get_maintainer
if __name__ == '__main__':
if 'GL_REPO' in os.environ:
# set by gitolite
repo = os.environ['GL_REPO']
else:
# otherwise, assume repository is the working directory
repo = os.getcwd()
maintainer = get_maintainer()
print('scallywag: invoked on repository {0}, by maintainer {1}'.format(repo, maintainer))
tokens = ''
for i in range(0, int(os.environ.get('GIT_PUSH_OPTION_COUNT', '0'))):
print('%s: %s' % ('GIT_PUSH_OPTION_%s' % i, os.environ['GIT_PUSH_OPTION_%s' % i]))
tokens += ' ' + os.environ['GIT_PUSH_OPTION_%s' % i].strip()
_, package = os.path.split(repo)
if package.endswith('.git'):
package, _ = os.path.splitext(package)
for line in sys.stdin.readlines():
old, new, ref = line.strip().split()
if ref.startswith('refs/heads/') and new != '0000000000000000000000000000000000000000':
# only do something if a branch ref is updated
request_build(new, ref, package, maintainer, tokens)